|
@@ -13,12 +13,16 @@ namespace UICatalog.Scenarios;
|
|
[ScenarioCategory ("Controls")]
|
|
[ScenarioCategory ("Controls")]
|
|
public class BackgroundWorkerCollection : Scenario
|
|
public class BackgroundWorkerCollection : Scenario
|
|
{
|
|
{
|
|
- public override void Run () { Application.Run<OverlappedMain> (); }
|
|
|
|
|
|
+ public override void Run ()
|
|
|
|
+ {
|
|
|
|
+ Application.Run<OverlappedMain> ();
|
|
|
|
+ Application.Top.Dispose ();
|
|
|
|
+ }
|
|
|
|
|
|
private class OverlappedMain : Toplevel
|
|
private class OverlappedMain : Toplevel
|
|
{
|
|
{
|
|
private readonly MenuBar _menu;
|
|
private readonly MenuBar _menu;
|
|
- private readonly WorkerApp _workerApp;
|
|
|
|
|
|
+ private WorkerApp _workerApp;
|
|
private bool _canOpenWorkerApp;
|
|
private bool _canOpenWorkerApp;
|
|
|
|
|
|
public OverlappedMain ()
|
|
public OverlappedMain ()
|
|
@@ -93,8 +97,6 @@ public class BackgroundWorkerCollection : Scenario
|
|
Activate += OverlappedMain_Activate;
|
|
Activate += OverlappedMain_Activate;
|
|
Deactivate += OverlappedMain_Deactivate;
|
|
Deactivate += OverlappedMain_Deactivate;
|
|
|
|
|
|
- Closed += OverlappedMain_Closed;
|
|
|
|
-
|
|
|
|
Application.Iteration += (s, a) =>
|
|
Application.Iteration += (s, a) =>
|
|
{
|
|
{
|
|
if (_canOpenWorkerApp && !_workerApp.Running && Application.OverlappedTop.Running)
|
|
if (_canOpenWorkerApp && !_workerApp.Running && Application.OverlappedTop.Running)
|
|
@@ -165,15 +167,15 @@ public class BackgroundWorkerCollection : Scenario
|
|
return new MenuBarItem ("_Window", new List<MenuItem []> { menuItems.ToArray () });
|
|
return new MenuBarItem ("_Window", new List<MenuItem []> { menuItems.ToArray () });
|
|
}
|
|
}
|
|
|
|
|
|
- private void OverlappedMain_Activate (object sender, ToplevelEventArgs top) { _workerApp.WriteLog ($"{top.Toplevel.Data} activate."); }
|
|
|
|
-
|
|
|
|
- private void OverlappedMain_Closed (object sender, ToplevelEventArgs e)
|
|
|
|
|
|
+ private void OverlappedMain_Activate (object sender, ToplevelEventArgs top)
|
|
{
|
|
{
|
|
- _workerApp.Dispose ();
|
|
|
|
- Dispose ();
|
|
|
|
|
|
+ _workerApp?.WriteLog ($"{top.Toplevel.Data} activate.");
|
|
}
|
|
}
|
|
|
|
|
|
- private void OverlappedMain_Deactivate (object sender, ToplevelEventArgs top) { _workerApp.WriteLog ($"{top.Toplevel.Data} deactivate."); }
|
|
|
|
|
|
+ private void OverlappedMain_Deactivate (object sender, ToplevelEventArgs top)
|
|
|
|
+ {
|
|
|
|
+ _workerApp?.WriteLog ($"{top.Toplevel.Data} deactivate.");
|
|
|
|
+ }
|
|
private void Quit () { RequestStop (); }
|
|
private void Quit () { RequestStop (); }
|
|
|
|
|
|
private MenuBarItem View ()
|
|
private MenuBarItem View ()
|
|
@@ -208,6 +210,15 @@ public class BackgroundWorkerCollection : Scenario
|
|
new List<MenuItem []> { menuItems.Count == 0 ? new MenuItem [] { } : menuItems.ToArray () }
|
|
new List<MenuItem []> { menuItems.Count == 0 ? new MenuItem [] { } : menuItems.ToArray () }
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <inheritdoc />
|
|
|
|
+ protected override void Dispose (bool disposing)
|
|
|
|
+ {
|
|
|
|
+ _workerApp?.Dispose ();
|
|
|
|
+ _workerApp = null;
|
|
|
|
+
|
|
|
|
+ base.Dispose (disposing);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private class Staging
|
|
private class Staging
|
|
@@ -299,7 +310,6 @@ public class BackgroundWorkerCollection : Scenario
|
|
|
|
|
|
public Staging Staging { get; private set; }
|
|
public Staging Staging { get; private set; }
|
|
public event Action<StagingUIController> ReportClosed;
|
|
public event Action<StagingUIController> ReportClosed;
|
|
- public void Run () { Application.Run (this); }
|
|
|
|
|
|
|
|
private void OnReportClosed (object sender, EventArgs e)
|
|
private void OnReportClosed (object sender, EventArgs e)
|
|
{
|
|
{
|
|
@@ -447,7 +457,8 @@ public class BackgroundWorkerCollection : Scenario
|
|
_stagingsUi.Add (stagingUI);
|
|
_stagingsUi.Add (stagingUI);
|
|
_stagingWorkers.Remove (staging);
|
|
_stagingWorkers.Remove (staging);
|
|
|
|
|
|
- stagingUI.Run ();
|
|
|
|
|
|
+ Application.Run (stagingUI);
|
|
|
|
+ stagingUI.Dispose ();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -465,8 +476,8 @@ public class BackgroundWorkerCollection : Scenario
|
|
|
|
|
|
_stagingWorkers.Add (staging, worker);
|
|
_stagingWorkers.Add (staging, worker);
|
|
worker.RunWorkerAsync ();
|
|
worker.RunWorkerAsync ();
|
|
- stagingUI.Dispose ();
|
|
|
|
}
|
|
}
|
|
|
|
+ stagingUI.Dispose ();
|
|
}
|
|
}
|
|
|
|
|
|
public void WriteLog (string msg)
|
|
public void WriteLog (string msg)
|