473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to wait for all processes on Background worker to complete

I am having troubles with a background worker that will have processes running. If the last process started on the background worker completes it calls the RunWorkCompleted method, even if all of the processes aren't complete. I want to start all of the processes at once, and wait until all are finished before it is complete:
Expand|Select|Wrap|Line Numbers
  1. private void TestRunning_DoWork(object sender, DoWorkEventArgs e)
  2.         {
  3.             procIDs = new int[CHKD];
  4.             int counter = 0;
  5.             foreach (TreeNode exe in myqueue)
  6.             {
  7.                 string exe2 = (string)exe.Text;
  8.                 string FullPath = "";
  9.                 //Make the tests run in background so the app doesn't pause
  10.                 {
  11.                     var TestSettings = new ProcessStartInfo(exe2, RunTestBuilder);
  12.                     TestSettings.RedirectStandardOutput = false;
  13.                     TestSettings.UseShellExecute = true;
  14.                     TestSettings.CreateNoWindow = true;
  15.                     TestSettings.WindowStyle = ProcessWindowStyle.Minimized;
  16.                     if (exe.Parent == null)
  17.                     {
  18.                         FullPath = di.ToString();
  19.                     }
  20.                     else
  21.                     {
  22.                         FullPath = di.ToString() + "\\" + exe.Parent.Text;
  23.                     }
  24.                     TestSettings.WorkingDirectory = FullPath;
  25.                     RunTests = new Process();
  26.                     RunTests.StartInfo = TestSettings;
  27.                     RunTests.Start();
  28.                     procIDs[counter] = RunTests.Id;
  29.                     appID = RunTests.SessionId;
  30.                     counter++;
  31.                 }
  32.             }
  33.             RunTests.WaitForExit();
  34.             if (TestRunning.CancellationPending)
  35.             {
  36.                 e.Cancel = true;
  37.                 return;
  38.             }
  39.         }
  40.  
Jun 24 '10 #1
0 1508

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: bryanjhogan | last post by:
Hi all, I have a GUI application that uses timers -------------------- TimerCallback readDelegate; TimerCallback deleteDelegate; private Timer readTimer; private Timer deleteTimer;
1
by: bilosta | last post by:
I need help with background worker and form I have a class (form1) that works with database. I need this: -Show form2 while form1 is geting data from database -When form1 is done, close form2,...
6
by: sjoshi | last post by:
I'm able to use the Bacground Worker class to execute task and pain the UI. However I want to be able to execute n tasks in order, say n1, then n2 if there were no errors during n1, n3 so on. ...
4
by: Jesse Aufiero | last post by:
I'm wondering what the rule is on how to assure that the background worker 'DoWork' routine is truly running entirely in the background. My DoWork routine calls another procedure which resides in...
4
by: csharpula csharp | last post by:
Hello, Can you please tell me if I should use the background worker in the following way: if (worker.IsBusy) worker.CancelAsync(); (or I can avoid this if)? And in case I want to restart the...
0
by: Smokey Grindel | last post by:
I have a search function that runs in a background worker which can run long.. I want the user to be able to cancel that then run another search... but sometimes it throws an exception saying ...
8
by: Analizer1 | last post by:
From what im reading about backgroundworker thread it seems it can only have 1 thread at a time is this correct tks
7
by: csharpula csharp | last post by:
Hello, I got a question regarding the usage of background worker. How can I run few threads via background worker with different objects as parameter each time. I understood that I can't do...
2
by: thoffman | last post by:
Hello again everyone! I have an issue that I can't seem to find a straight answer for anywhere... I have a For loop that sends a file name to a background worker that contains some long running...
1
by: Infog | last post by:
I am trying to code a simple background workers class without needing to use the backgroundworker object on a form. This would allow me to use a background worker in any class without writing much...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.