public void DoAllActions() { PreventAutoScan("Do all actions"); ItemList theList = new ItemList(); theList.AddRange(TheActionList.Actions()); DoActions(theList); AllowAutoScan(); }
/// <summary> /// Processes a set of actions, running them in a multi-threaded way based on the application's settings. /// </summary> /// <param name="theList">An ItemList to be processed.</param> /// <param name="showUi">Whether or not we should display a UI to inform the user about progress.</param> public void DoActions([CanBeNull] ItemList theList, bool showUi) { if (theList is null) { Logger.Info("Asked to do actions, but none provided...."); return; } Logger.Info("**********************"); Logger.Info($"Doing Selected Actions.... ({theList.Count} items detected, {theList.Actions().Count()} actions to be completed )"); // Run tasks in parallel (as much as is sensible) ActionQueue[] queues = ActionProcessorMakeQueues(theList); actionPause = false; // If not /hide, show CopyMoveProgress dialog /* * CopyMoveProgress cmp = null; * if (showUi) * { * cmp = new CopyMoveProgress(this, queues); * } * * Thread actionProcessorThread = new Thread(ActionProcessor) * { * Name = "ActionProcessorThread" * }; * * actionProcessorThread.Start(queues); * * if ((cmp != null) && (cmp.ShowDialog() == DialogResult.Cancel)) * { * actionProcessorThread.Abort(); * } * * actionProcessorThread.Join(); */ theList.RemoveAll(x => (x is Action action) && action.Done && !action.Error); foreach (Action slia in theList.Actions()) { Logger.Warn("Failed to complete the following action: {0}, doing {1}. Error was {2}", slia.Name, slia.ToString(), slia.ErrorText); } Logger.Info("Completed Selected Actions"); Logger.Info("**************************"); }
/// <summary> /// Processes a set of actions, running them in a multi-threaded way based on the application's settings. /// </summary> /// <param name="theList">An ItemList to be processed.</param> /// <param name="showUi">Whether or not we should display a UI to inform the user about progress.</param> public void DoActions([CanBeNull] ItemList theList, bool showUi) { if (theList is null) { Logger.Info("Asked to do actions, but none provided...."); return; } Logger.Info("**********************"); Logger.Info($"Doing Selected Actions.... ({theList.Count} items detected, {theList.Actions().Count()} actions to be completed )"); // Run tasks in parallel (as much as is sensible) ActionQueue[] queues = ActionProcessorMakeQueues(theList); actionPause = false; // If not /hide, show CopyMoveProgress dialog CopyMoveProgress cmp = null; if (showUi) { cmp = new CopyMoveProgress(this, queues); } Thread actionProcessorThread = new Thread(ActionProcessor) { Name = "ActionProcessorThread" }; actionProcessorThread.Start(queues); if (cmp != null && cmp.ShowDialog() == DialogResult.Cancel) { actionProcessorThread.Abort(); } actionProcessorThread.Join(); theList.RemoveAll(x => x is Action action && action.Outcome.Done && !action.Outcome.Error); foreach (Action slia in theList.Actions()) { Logger.Warn(slia.Outcome.LastError, $"Failed to complete the following action: {slia.Name}, doing {slia}. Error was {slia.Outcome.LastError?.Message}"); } Logger.Info("Completed Selected Actions"); Logger.Info("**************************"); }