Ummm... Ok, not to sound like a smarta$$ or anything, but one way to make sure the operation is complete before the method returns is to just run it synchornously (i.e. not in the background).
Or is there a specific reason you want it in the background thread (keep the UI thread resposive?). --- Patrick Steele http://weblogs.asp.net/psteele -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Chopra, Arvinder [Beeline] Sent: Thursday, July 19, 2007 1:57 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] Question about the right way to use BackGroundWorker Consider this pseudocode: Public void DoSomething() { Foreach (pending_job job in ListOfPendingJobs) { job.ExecuteLongOperation(); } Return to caller; } What I want to do is to execute the job.ExecuteLongOperation() on a separate thread using BackGroundWorker(). The question is what is the best practice/pattern to make sure all BackGroundWorkers have finished execution before the above method returns. Thanks =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com