Having trouble running multiple processes one after another from within backgroundworker
First processes, regardless which one I put as first seems to run, however nothing occurs afterwards.
Please excuse my ignorant, I cant seem to find what I am looking for,
Wondering if someone can shed some light on
wether I am using wrong method or is it something simple I can't see
Here is a section of the code:
First processes, regardless which one I put as first seems to run, however nothing occurs afterwards.
Please excuse my ignorant, I cant seem to find what I am looking for,
Wondering if someone can shed some light on
wether I am using wrong method or is it something simple I can't see
Here is a section of the code:
private BackgroundWorker BackgroundWorker = new BackgroundWorker();
public Form1()
{
InitializeComponent();
BackgroundWorker.WorkerSupportsCancellation = true;
BackgroundWorker.WorkerReportsProgress = true;
BackgroundWorker.DoWork += BackgroundWorker1_DoWork;
BackgroundWorker.ProgressChanged += BackgroundWorker1_ProgressChanged;
BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorker1_RunWorkerCompleted);
}
private void Button1_Click(object sender, EventArgs e)
{
if (!BackgroundWorker1.IsBusy)
{
BackgroundWorker1.RunWorkerAsync();
}
else
{
label2.Text = "Busy processing, please wait";
}
}
private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
if(!File.Exists("proc1.ps1"))
File.WriteAllBytes("proc1.ps1", SOL.Properties.Resources.proc1);
if (!File.Exists("proc2"))
File.WriteAllBytes("proc2", SOL.Properties.Resources.proc2);
if (!File.Exists("proc3"))
File.WriteAllBytes("proc3", SOL.Properties.proc3);
Process proc1 = new Process();
proc1.StartInfo.FileName = @"proc1.exe";
proc1.StartInfo.Arguments = (@"–ExecutionPolicy Bypass ""proc.ps1""");
proc1.Start();
proc1.WaitForExit();
Process proc2 = new Process();
pro2.StartInfo.FileName = "proc2.exe";
pro2.Start();
pro2.WaitForExit();
Process proc3 = new Process();
pro3.StartInfo.FileName = "proc3.exe";
pro3.Start();
pro3.WaitForExit();