private void btnStartStop_Click(object sender, EventArgs e) { try { if (!backgroundWorkerPackUnpack.IsBusy) { GxExpander expander = new GxExpander(); expander.Mode = radioButtonModeUnpack.Checked ? GxExpanderMode.Unpack : GxExpanderMode.Pack; expander.Game = (GxGame)cmbGame.SelectedValue; expander.InputPath = txtInputPath.Text; expander.OutputPath = txtOutputPath.Text; expander.BackgroundWorker = backgroundWorkerPackUnpack; backgroundWorkerPackUnpack.RunWorkerAsync(expander); UpdateStartStopButtonText(); } else { backgroundWorkerPackUnpack.CancelAsync(); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error starting the process", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void backgroundWorkerPackUnpack_DoWork(object sender, DoWorkEventArgs e) { GxExpander expanderForBackgroundWorker = (GxExpander)e.Argument; expanderForBackgroundWorker.Run(); }