move ui lifetime to a manager for better lifetime control
This commit is contained in:
@@ -93,27 +93,11 @@ namespace Torch.Server
|
||||
#endif
|
||||
|
||||
_server.Init();
|
||||
|
||||
var uiThread = new Thread(() =>
|
||||
{
|
||||
var ui = new TorchUI(_server);
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
|
||||
|
||||
ui.ShowDialog();
|
||||
});
|
||||
|
||||
uiThread.SetApartmentState(ApartmentState.STA);
|
||||
uiThread.Start();
|
||||
|
||||
if (Config.Autostart || Config.TempAutostart)
|
||||
{
|
||||
Config.TempAutostart = false;
|
||||
_server.Start();
|
||||
}
|
||||
|
||||
uiThread.Join();
|
||||
if (!Config.Autostart && !Config.TempAutostart) return;
|
||||
|
||||
Config.TempAutostart = false;
|
||||
_server.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user