private void ProcessFilesButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(chosenPath.Trim())) { return; } StatusLabelText.Text = "Processing"; ProcessFilesButton.BeginInvoke((MethodInvoker) delegate() { ProcessFilesButton.Enabled = false; }); ChooseFirstFolderButton.BeginInvoke((MethodInvoker) delegate() { ChooseFirstFolderButton.Enabled = false; }); SearchByMiddleNamesCB.BeginInvoke((MethodInvoker) delegate() { SearchByMiddleNamesCB.Enabled = false; }); try { new Task(() => { Thread t = new Thread(RunProgram); t.Start(); t.Join(); StatusLabelText.BeginInvoke((MethodInvoker) delegate() { StatusLabelText.Text = "Finish"; }); ProcessFilesButton.BeginInvoke((MethodInvoker) delegate() { ProcessFilesButton.Enabled = true; }); ChooseFirstFolderButton.BeginInvoke((MethodInvoker) delegate() { ChooseFirstFolderButton.Enabled = true; }); SearchByMiddleNamesCB.BeginInvoke((MethodInvoker) delegate() { SearchByMiddleNamesCB.Enabled = true; }); Console.WriteLine("Finish"); }).Start(); } catch (Exception) { StatusLabelText.Text = "Something wrong"; } }
private void ProcessFilesButton_Click(object sender, EventArgs e) { if (!CanRunProcess()) { MessageBox.Show("Need to specify both files", "Processing cannot be started!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ms = new ShareholderAnalyzerLogic(chosenPath, choosenTermsFilePath); if (string.IsNullOrEmpty(chosenPath.Trim())) { return; } StatusLabelText.Text = "Processing"; ProcessFilesButton.BeginInvoke((MethodInvoker) delegate() { ProcessFilesButton.Enabled = false; }); ChooseFirstFolderButton.BeginInvoke((MethodInvoker) delegate() { ChooseFirstFolderButton.Enabled = false; }); try { new Task(() => { Thread t = new Thread(RunProgram); t.Start(); t.Join(); StatusLabelText.BeginInvoke((MethodInvoker) delegate() { StatusLabelText.Text = "Finish"; }); ProcessFilesButton.BeginInvoke((MethodInvoker) delegate() { ProcessFilesButton.Enabled = true; }); ChooseFirstFolderButton.BeginInvoke((MethodInvoker) delegate() { ChooseFirstFolderButton.Enabled = true; }); Console.WriteLine("Finish"); }).Start(); } catch (Exception) { StatusLabelText.Text = "Something wrong"; } }