public Task Handle(ApplicationShutdownRequested notification, CancellationToken cancellationToken) { // stop worker queue that persists measurements CancellationTokenSource.Cancel(); // wait for stop to complete return(Task.CompletedTask); }
private async void DownloadAsync() { IsSkipButtonVisible = false; IsDownloadButtonVisible = false; IsCancelButtonVisible = false; IsInterruptButtonVisible = true; string downloadFilePath = null; MainModel.DownloadFileResult?result = null; try { string downloadDirectory = Path.Combine(Environment.AppDataDirectory, "Updates"); if (!Directory.Exists(downloadDirectory)) { Directory.CreateDirectory(downloadDirectory); } downloadFilePath = Path.Combine(downloadDirectory, updateCheckResult.FileName); Progress <object> downloadProgressHandler = new Progress <object>(HandleDownloadProgress); result = await MainModel.DownloadFileAsync(updateCheckResult.DownloadUrl, downloadFilePath, downloadProgressHandler, cancellationTokenSource.Token); } catch (Exception exception) { ShowErrorWindow(exception, CurrentWindowContext); error = true; } if (!error && result != MainModel.DownloadFileResult.COMPLETED) { if (result == MainModel.DownloadFileResult.INCOMPLETE) { ShowMessage(Localization.Error, Localization.IncompleteDownload); } error = true; } IsInterruptButtonVisible = false; IsCloseButtonVisible = true; if (!error) { if (Environment.IsInPortableMode) { Process.Start("explorer.exe", $@"/select, ""{downloadFilePath}"""); CurrentWindowContext.CloseDialog(false); } else { Process.Start(downloadFilePath); CurrentWindowContext.CloseDialog(false); ApplicationShutdownRequested?.Invoke(this, EventArgs.Empty); } } }
private async void DownloadAsync() { IsSkipButtonVisible = false; IsDownloadButtonVisible = false; IsCancelButtonVisible = false; IsInterruptButtonVisible = true; Updater.UpdateDownloadResult result = null; try { Progress <object> downloadProgressHandler = new Progress <object>(HandleDownloadProgress); result = await MainModel.Updater.DownloadUpdateAsync(updateCheckResult, downloadProgressHandler, cancellationTokenSource.Token); } catch (Exception exception) { ShowErrorWindow(exception, CurrentWindowContext); error = true; } if (!error && result.DownloadResult != DownloadUtils.DownloadResult.COMPLETED) { if ((result.DownloadResult == DownloadUtils.DownloadResult.INCOMPLETE) || (result.DownloadResult == DownloadUtils.DownloadResult.ERROR)) { ShowMessage(Localization.Error, Localization.IncompleteDownload); } error = true; } IsInterruptButtonVisible = false; IsCloseButtonVisible = true; if (!error) { if (Environment.IsInPortableMode) { Process.Start("explorer.exe", $@"/select, ""{result.DownloadFilePath}"""); CurrentWindowContext.CloseDialog(false); } else { Process.Start(result.DownloadFilePath); CurrentWindowContext.CloseDialog(false); ApplicationShutdownRequested?.Invoke(this, EventArgs.Empty); } } }
public void Handle(ApplicationShutdownRequested message) { _logger.Info("Shutting down task execution"); _cancellationTokenSource.Cancel(true); }
public void Handle(ApplicationShutdownRequested message) { _logger.Info("Shutting down scheduler"); _cancellationTokenSource.Cancel(true); Timer.Stop(); }
public Task Handle(ApplicationShutdownRequested notification, CancellationToken cancellationToken) { IsShutdownRequested = true; return(Task.CompletedTask); }
public void Handle(ApplicationShutdownRequested message) { _cancellationTokenSource.Cancel(true); Timer.Stop(); }
void OnShutdownCore(ApplicationShutdownReason reason) { #if !SILVERLIGHT var canceled = false; #endif try { #if !SILVERLIGHT if (reason == ApplicationShutdownReason.UserRequest && this.isBootCompleted) { //messaggio per notificare ed eventualmente cancellare var msg = new ApplicationShutdownRequested(reason); var broker = this.GetService <IMessageBroker>(); broker.Dispatch(this, msg); canceled = msg.Cancel; if (canceled) { broker.Broadcast(this, new ApplicationShutdownCanceled(reason)); return; } } #endif this.IsShuttingDown = true; if (this.isBootCompleted) { this.GetService <IMessageBroker>().Broadcast(this, new ApplicationShutdown(reason)); var callbacks = this.ResolveAll <IExpectShutdownCallback>(); if (callbacks != null && callbacks.Any()) { foreach (var cb in callbacks) { cb.OnShutdown(reason); } } } var args = new ApplicationShutdownArgs() { Reason = reason, IsBootCompleted = this.isBootCompleted }; this.OnShutdown(args); if (this.shutdownHandler != null) { this.shutdownHandler(args); } if (this.isBootCompleted) { this.catalog.Dispose(); this.compositionContainer.Dispose(); if (this.serviceProvider is IDisposable) { (( IDisposable )this.serviceProvider).Dispose(); } } #if !SILVERLIGHT if (this.mutex != null) { this.mutex.Dispose(); this.mutex = null; } #endif } finally { #if !SILVERLIGHT if (!canceled && reason != ApplicationShutdownReason.ApplicationRequest) { Application.Current.Shutdown(); } #endif #if !SILVERLIGHT if (!canceled) { this.catalog = null; this.compositionContainer = null; this.serviceProvider = null; RegionService.CurrentService = null; RegionService.Conventions = null; } #else this.catalog = null; this.compositionContainer = null; this.serviceProvider = null; RegionService.CurrentService = null; RegionService.Conventions = null; #endif } }
public Task Handle(ApplicationShutdownRequested notification, CancellationToken cancellationToken) { CancellationTokenSource.Cancel(); return(Task.CompletedTask); }