Files
duplicati/Duplicati/GUI/Duplicati.GUI.TrayIcon/HostedInstanceKeeper.cs
T
kenneth@hexad.dk 11c8f232b7 Fixed a quit problem.
Changed the status reporting method to not include status for the current running backup.
That will be implemented with a separate call so the tray icon can reduce the number of requests.

git-svn-id: https://duplicati.googlecode.com/svn/trunk@1332 59da171f-624f-0410-aa54-27559c288bec
2012-06-06 12:58:27 +00:00

52 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Duplicati.GUI.TrayIcon
{
/// <summary>
/// We keep the hosted instance here to allow the TrayIcon executable to load without requiring the Server.exe
/// </summary>
internal class HostedInstanceKeeper : IDisposable
{
private System.Threading.Thread m_runner;
private System.Exception m_runnerException = null;
public HostedInstanceKeeper(string[] args)
{
m_runner = new System.Threading.Thread(ThreadRunner);
m_runner.Start(args);
if (!Duplicati.Server.Program.ServerStartedEvent.WaitOne(TimeSpan.FromSeconds(100), true))
{
if (m_runnerException != null)
throw m_runnerException;
else
throw new Exception("Hosted server startup timed out");
}
}
private void ThreadRunner(object a)
{
try
{
Duplicati.Server.Program.Main((string[])a);
} catch (Exception ex) {
m_runnerException = ex;
}
}
public void Dispose()
{
Duplicati.Server.Program.ApplicationExitEvent.Set();
if (!m_runner.Join(TimeSpan.FromSeconds(10)))
{
m_runner.Abort();
m_runner.Join(TimeSpan.FromSeconds(10));
}
}
}
}