I have a problem concerning the System.Threading
Microsoft .NET namespace. In this namespace, many classes are defined in order to help me managing with threads.
Well, I have a problem, but I do not know what to use, MSDN is vague and I still haven't got a clue of what classes do what. in particular, my problem concerns synchronization.
The problem
I have a certain number of threads (consider N threads). At a certain point a thread must stop and wait for at least one of the other thread to do something. Once one of the N - 1 threads has done a certain task, this thread notifies and the stopped thread will be able to proceed.
So it is just a synchronization issue: a thread must wait to be signalled, that's all.
Many classes
In System.Threading
there are many classes provided in order to handle synchronization issues. There are WaitHandle
(s), there are AutoResetEvent
(s), there are ManualResetEvent
(s) and so on...
Which one whould I use?
The question
My question is: can anybody summarize me which class I should use in order to solve my problem? Could you please tell the most important differences between these classes, or other classes?
The point is that I havn't really understood what class is responsible of in the synchronization matter: what is the difference, for example, between a WaitHandle
and an AutoResetEvent
or ManualResetEvent
?
What about lock?
In order to handle many threading issue, .net provides lock
functionalities and the Monitor
class. Is this couple good for my needs?
Thankyou