Newbie question.

  • Thread starter Thread starter Sami
  • Start date Start date
S

Sami

Hello,
I just started learning .NET programming under C#.

In C++ I use Event objects and WaitForMultipleObjects for Thread
synchronization.

What is the equivalent og Event objects under .NET/C#?
 
Sami,

In .NET, for those kind of notification events, you would use the Event
class. Once you have an instance of the Event class, you can wait for that
by calling the WaitOne method on the event.

If you want to wait on multiple objects, then you can call the static
WaitAll or WaitAny methods on the WaitHandle class. However, you can not
call WaitAll on a thread that is a single threaded apartment (any UI thread
basically).

Hope this helps.
 
System.Threading.AutoResetEvent and System.Threading.ManualResetEvent

and

WaitHandle.WaitOne

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

Hello,
I just started learning .NET programming under C#.

In C++ I use Event objects and WaitForMultipleObjects for Thread
synchronization.

What is the equivalent og Event objects under .NET/C#?
 
If you are really looking to get into .Net, I suggest you purchase Juval
Lowy's book on Programming .Net Components. Chapter 6 - Events, Chapter - 7
Asynchronous Calls and Chapter - 8 Multithreading and Concurrency Management,
might answer some of the questions you are having right now.
 
Back
Top