Skip to content

Commit

Permalink
Fix TestBA to always shutdown properly
Browse files Browse the repository at this point in the history
  • Loading branch information
robmen committed Feb 29, 2024
1 parent 8daad15 commit 577e145
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/test/burn/TestBA/TestBA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ protected override void OnStartup(StartupEventArgs args)

base.OnStartup(args);

int redetectCount;
string redetect = this.ReadPackageAction(null, "RedetectCount");
if (String.IsNullOrEmpty(redetect) || !Int32.TryParse(redetect, out redetectCount))
if (String.IsNullOrEmpty(redetect) || !Int32.TryParse(redetect, out var redetectCount))
{
redetectCount = 0;
}
Expand Down Expand Up @@ -180,20 +179,15 @@ protected override void OnStartup(StartupEventArgs args)

protected override void Run()
{
this.dummyWindow = new Form();
this.windowHandle = this.dummyWindow.Handle;
using (this.dummyWindow = new Form())
{
this.windowHandle = this.dummyWindow.Handle;

this.Log("Running TestBA application");
this.wait.Set();
Application.Run();
}
this.Log("Running TestBA application");
this.wait.Set();

private void ShutdownUiThread()
{
if (this.dummyWindow != null)
{
this.dummyWindow.Invoke(new Action(Application.ExitThread));
this.dummyWindow.Dispose();
Application.Run();
this.dummyWindow = null;
}

var exitCode = this.result;
Expand All @@ -205,6 +199,18 @@ private void ShutdownUiThread()
this.Engine.Quit(exitCode);
}

private void ShutdownUiThread()
{
try
{
this.dummyWindow?.Invoke(new Action(Application.ExitThread));
}
catch (Exception e)
{
this.Log("Failed to shutdown TestBA window, exception: {0}", e.Message);
}
}

protected override void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args)
{
this.Log("OnDetectUpdateBegin");
Expand Down

0 comments on commit 577e145

Please sign in to comment.