/// <summary> /// A function that blocks until all threads in the supplied closing worker are complete and closed. /// This function will display status in a persistent dialog. /// </summary> /// <param name="closingWorker">The ClosingWorker to perform the actions on.</param> public static void WaitForThreadsToCloseDialogOutput(this ClosingWorker closingWorker) { // run the closing worker until all child threads are closed ClosingInfo status; var cycles = 0; while ((status = closingWorker.ShutdownThreads()).ShutdownReady == false) { if (++cycles % 6 == 0) { if (!CrossThreadDialogs.MessageBoxPersistentExists()) { CrossThreadDialogs.MessageBoxPersistentCreate(new DialogConfiguration { Message = status.Message, Title = "CV-LS Dashboard Closing Status", ButtonIsVisible = false, DialogWidth = 600, MessageAlignment = ContentAlignment.MiddleLeft }); } else { CrossThreadDialogs.MessageBoxPersistentUpdateMessage(status.Message); } } TimeFunctions.Wait(50); } CrossThreadDialogs.MessageBoxPersistentClose(); }
/// <summary> /// A function that blocks until all threads in the supplied closing worker are complete and closed. /// This function will display status in the console. /// </summary> /// <param name="closingWorker">The ClosingWorker to perform the actions on.</param> public static void WaitForThreadsToCloseNoOutput(this ClosingWorker closingWorker) { // run the closing worker until all child threads are closed while (closingWorker.ShutdownThreads().ShutdownReady == false) { TimeFunctions.Wait(50); } }
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) { _applicationSettings.FormSettings.SaveLocation(this); _applicationSettings.WriteSettings(); _docking.SaveLayout(); _closingWorker.ShutdownThreads(); }
/// <summary> /// A function that blocks until all threads in the supplied closing worker are complete and closed. /// This function will display status in the console. /// </summary> /// <param name="closingWorker">The ClosingWorker to perform the actions on.</param> public static void WaitForThreadsToCloseConsoleOutput(this ClosingWorker closingWorker) { // run the closing worker until all child threads are closed ClosingInfo status; var cycles = 0; var previousLines = 0; while ((status = closingWorker.ShutdownThreads()).ShutdownReady == false) { if (cycles++ % 6 == 0) { ConsoleFunctions.ClearLine(previousLines); Console.WriteLine(status.Message); previousLines = status.Message.Split('\r').Length; } TimeFunctions.Wait(50); } // clean up console ConsoleFunctions.ClearLine(previousLines); Console.WriteLine("Shutdown Threads Complete!"); }