public void GetTaskDetails(int numberOfFiles, int currentFile, string fileName, string fileExtension, string fileNewName) { try { NumberOfFiles = numberOfFiles; if (numberOfFiles > 0) { CurrentFile = currentFile; FileName = fileName; FileExtension = fileExtension; FileNewName = fileNewName; if (MatchedFileGroupBox.InvokeRequired) { MatchedFileGroupBox.Invoke((MethodInvoker)ShowTaskDetails); } if (currentFile == numberOfFiles) { ((TaskRunnerButton)TasksFlowPanel.Controls[TaskIndex]).ChangeRunning(false); if (++TaskIndex < TaskCount) { StartTaskThread(); } else if (GroupStatusValue.InvokeRequired) { GroupStatusValue.Invoke((MethodInvoker)OnGroupComplete); } } } else if (numberOfFiles == 0) { ((TaskRunnerButton)TasksFlowPanel.Controls[TaskIndex]).ChangeRunning(false); if (++TaskIndex < TaskCount) { StartTaskThread(); } else if (MatchedFileGroupBox.InvokeRequired) { MatchedFileGroupBox.Invoke((MethodInvoker)OnGroupComplete); } } else { if (MatchedFileGroupBox.InvokeRequired) { MatchedFileGroupBox.Invoke((MethodInvoker)ShowTaskDetails); } } } catch { MatchedFileGroupBox.Invoke((MethodInvoker)ShowTaskDetails); } }
public void StartTaskThread() { if (TaskCollectionObject.TaskList[TaskIndex].Enabled) { ((TaskRunnerButton)TasksFlowPanel.Controls[TaskIndex]).ChangeRunning(true); Thread PerformTaskThread = new Thread(() => TaskCollectionObject.TaskList[TaskIndex].PerformTask(GetTaskDetailsDelegate, VerboseOption)); PerformTaskThread.IsBackground = true; PerformTaskThread.Start(); } else if (++TaskIndex < TaskCount) { StartTaskThread(); } else if (MatchedFileGroupBox.InvokeRequired) { MatchedFileGroupBox.Invoke((MethodInvoker)OnGroupComplete); } }