Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 7ee2471

Browse files
committed
server now closes properly on program exit
1 parent 59020e0 commit 7ee2471

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

UI/MainWindow/MainWindow.xaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ private void DockingPaneGroup_ChildrenTreeChanged(object sender, ChildrenTreeCha
173173

174174
private void MetroWindow_Closing(object sender, CancelEventArgs e)
175175
{
176-
ServerCheckThread?.Abort(); //a join would not work, so we have to be..forcefully...
176+
if (ServerIsRunning)
177+
{
178+
ServerCheckThread.Abort();
179+
ServerProcess.Kill();
180+
}
177181
var lastOpenFiles = new List<string>();
178182
var editors = GetAllEditorElements();
179183
bool? SaveUnsaved = null;
@@ -447,7 +451,7 @@ public void UpdateWindowTitle()
447451

448452
if (ServerIsRunning)
449453
{
450-
outString = $"{outString} | ({Program.Translations.GetLanguage("ServerRunning")})";
454+
outString = $"{outString} | {Program.Translations.GetLanguage("ServerRunning")}";
451455
}
452456

453457
Title = outString;

UI/MainWindow/MainWindowSPCompiler.cs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -496,30 +496,29 @@ private void ProcessCheckWorker()
496496
try
497497
{
498498
ServerProcess.Start();
499+
ServerIsRunning = true;
500+
Program.MainWindow.Dispatcher?.Invoke(() =>
501+
{
502+
EnableServerAnim.Begin();
503+
UpdateWindowTitle();
504+
});
505+
ServerProcess.WaitForExit();
506+
ServerProcess.Dispose();
507+
ServerIsRunning = false;
508+
Program.MainWindow.Dispatcher?.Invoke(() =>
509+
{
510+
if (Program.MainWindow.IsLoaded)
511+
{
512+
DisableServerAnim.Begin();
513+
UpdateWindowTitle();
514+
}
515+
LoggingControl.LogAction("Server started.", 2);
516+
});
499517
}
500518
catch (Exception)
501519
{
502520
return;
503521
}
504-
505-
ServerIsRunning = true;
506-
Program.MainWindow.Dispatcher?.Invoke(() =>
507-
{
508-
EnableServerAnim.Begin();
509-
UpdateWindowTitle();
510-
});
511-
ServerProcess.WaitForExit();
512-
ServerProcess.Dispose();
513-
ServerIsRunning = false;
514-
Program.MainWindow.Dispatcher?.Invoke(() =>
515-
{
516-
if (Program.MainWindow.IsLoaded)
517-
{
518-
DisableServerAnim.Begin();
519-
UpdateWindowTitle();
520-
}
521-
LoggingControl.LogAction("Server started.", 2);
522-
});
523522
}
524523

525524
private string ShortenScriptFileName(string fileName)

0 commit comments

Comments
 (0)