Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Diagnostic.Process Pin
Paul Watson1-Jan-05 10:19
sitebuilderPaul Watson1-Jan-05 10:19 
GeneralGlobal Shortcut Pin
elitecodex29-Dec-04 12:21
elitecodex29-Dec-04 12:21 
GeneralRe: Global Shortcut Pin
Adam Goossens29-Dec-04 14:50
Adam Goossens29-Dec-04 14:50 
GeneralRe: Global Shortcut Pin
elitecodex30-Dec-04 0:24
elitecodex30-Dec-04 0:24 
GeneralCLosing threads Pin
Ista29-Dec-04 11:56
Ista29-Dec-04 11:56 
GeneralRe: CLosing threads Pin
Adam Goossens29-Dec-04 14:35
Adam Goossens29-Dec-04 14:35 
GeneralRe: CLosing threads Pin
Ista30-Dec-04 4:53
Ista30-Dec-04 4:53 
GeneralRe: CLosing threads Pin
Adam Goossens30-Dec-04 13:03
Adam Goossens30-Dec-04 13:03 
Hi Nick.

First I suggest you read the documentation on the System.Threading.ManualResetEvent class (here). In a nutshell:

The ManualResetEvent provides a way for you to notify other threads when you have completed a task.

All Class A needs to do is provide it's own ManualResetEvent that the controller can access and store away. Once all of the threads are created the controller can then call System.Threading.WaitHandle.WaitAny(), passing in an array of the ManualResetEvents (one per class object you created) that it kept. As ManualResetEvent derives from WaitHandle, this is perfectly valid.

The call to WaitHandle.WaitAny() will then block the controlling thread until one of the ManualResetEvents you supplied is set to signalled (ie, indicating that a class on another thread finished processing - you don't know which one, but you know that at least one of them has finished).

Once this occurs, the controller thread will then be allowed to continue, regardless of whether the other threads have finished processing or not (that is possible because you called WaitAny, not WaitAll).

Now, you asked how the WaitHandle notifies the other threads that it has been signalled. That one I don't know, sorry. I might do some research into it, however.

If you need any more help, let me know.

Good luck.

This space for rent!
My Blog
GeneralThread and Not Responding Pin
brunoconde29-Dec-04 9:48
brunoconde29-Dec-04 9:48 
GeneralRe: Thread and Not Responding Pin
Tom Larsen29-Dec-04 10:49
Tom Larsen29-Dec-04 10:49 
GeneralRe: Thread and Not Responding Pin
Heath Stewart29-Dec-04 11:23
protectorHeath Stewart29-Dec-04 11:23 
GeneralRe: Thread and Not Responding Pin
Tom Larsen30-Dec-04 4:29
Tom Larsen30-Dec-04 4:29 
GeneralRe: Thread and Not Responding Pin
Heath Stewart30-Dec-04 5:17
protectorHeath Stewart30-Dec-04 5:17 
GeneralRe: Thread and Not Responding Pin
Heath Stewart29-Dec-04 11:06
protectorHeath Stewart29-Dec-04 11:06 
GeneralRe: Thread and Not Responding Pin
PaleyX1-Apr-05 2:50
PaleyX1-Apr-05 2:50 
GeneralRe: Thread and Not Responding Pin
Heath Stewart1-Apr-05 7:03
protectorHeath Stewart1-Apr-05 7:03 
GeneralRe: Thread and Not Responding Pin
PaleyX1-Apr-05 7:17
PaleyX1-Apr-05 7:17 
GeneralRe: Thread and Not Responding Pin
Heath Stewart2-Apr-05 1:25
protectorHeath Stewart2-Apr-05 1:25 
GeneralRe: Thread and Not Responding Pin
PaleyX2-Apr-05 1:53
PaleyX2-Apr-05 1:53 
GeneralRe: Thread and Not Responding Pin
Heath Stewart3-Apr-05 6:41
protectorHeath Stewart3-Apr-05 6:41 
GeneralRe: Thread and Not Responding Pin
PaleyX4-Apr-05 5:37
PaleyX4-Apr-05 5:37 
GeneralRe: Thread and Not Responding Pin
Heath Stewart4-Apr-05 8:23
protectorHeath Stewart4-Apr-05 8:23 
GeneralRe: Thread and Not Responding Pin
Ashar Khaliq29-Dec-04 11:17
Ashar Khaliq29-Dec-04 11:17 
GeneralRe: Thread and Not Responding Pin
brunoconde30-Dec-04 2:47
brunoconde30-Dec-04 2:47 
GeneralRe: Thread and Not Responding Pin
Heath Stewart30-Dec-04 5:14
protectorHeath Stewart30-Dec-04 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.