public void Shutdown() { if (!PendingClose) { PendingClose = true; EDDNSync.StopSync(); EdsmSync.StopSync(); EdsmLogFetcher.Stop(); journalmonitor.StopMonitor(); LogLineHighlight("Closing down, please wait.."); Console.WriteLine("Close.. safe close launched"); closeRequested.Set(); } }
private void BackgroundRefreshWorkerThread() { WaitHandle.WaitAny(new WaitHandle[] { closeRequested, readyForNewRefresh }); // Wait to be ready for new refresh after initial refresh while (!PendingClose) { int wh = WaitHandle.WaitAny(new WaitHandle[] { closeRequested, refreshRequested }); RefreshWorkerArgs argstemp = null; RefreshWorkerArgs args = null; if (PendingClose) { break; } switch (wh) { case 0: // Close Requested break; case 1: // Refresh Requested journalmonitor.StopMonitor(); // this is called by the foreground. Ensure background is stopped. Foreground must restart it. EdsmLogFetcher.Stop(); InvokeAsyncOnUiThread(() => { OnRefreshStarting?.Invoke(); }); while (refreshWorkerQueue.TryDequeue(out argstemp)) // Get the most recent refresh { args = argstemp; } if (args != null) { readyForNewRefresh.Reset(); DoRefreshHistory(args); WaitHandle.WaitAny(new WaitHandle[] { closeRequested, readyForNewRefresh }); // Wait to be ready for new refresh } break; } } }