/// <summary>Handle exception throw during ICommand execution</summary> /// <param name="ex"></param> protected virtual void HandleException(Exception ex) { LogTo.Error(ex, "Exception occured during a user requested operation on a plugin"); Dispatcher.Invoke( () => { var errMsg = $"Operation failed with error: {ex.Message}"; OperationLogs.AppendLine(errMsg); errMsg.ErrorMsgBox(); } ); }
protected void LogOperationOutput(string msg) { var match = PluginManagerLogAdapter.RE_Anotar.Match(msg); if (match.Success) { msg = match.Groups[match.Groups.Count - 1].Value; } Dispatcher.Invoke(() => { OperationLogs.AppendLine(msg); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OperationLogs))); }); }
/// <summary>Cancel running tasks using <see cref="CancellationTokenSource" /></summary> public void CancelTasks() { switch (Status) { case PluginManagerStatus.Install: Dispatcher.InvokeAsync(() => OperationLogs.AppendLine("\nCancelling...")); break; } try { CancellationTokenSource?.Cancel(); } catch (ObjectDisposedException) { } }