Peter, My solution creates Thread objects for each of Arvinder's pending job classes and joins those threads together for synchronization. If the pending job calculations consume shared resources, then my solution could result in a deadlock... good point.
Arvinder, Could you provide a more detailed explanation about the activities of the pending job? Kara On 7/19/07, Chopra, Arvinder [Beeline] <[EMAIL PROTECTED]> wrote:
The reason is that I would like to finish the pending jobs as soon as possible. The time lag between the start time of the first job, and finish of the last job is unacceptable. I have a quad processor machine, and I would to take advantage of the additional CPUs. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Patrick Steele Sent: Thursday, July 19, 2007 12:32 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Question about the right way to use BackGroundWorker 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(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) 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