interviews.dotnetthread.com

↑ Grab this Headline Animator

Wednesday, May 14, 2008

How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?

You want the lock statement, which is the same as Monitor Enter/Exit:
lock(obj) { // code }
translates to

try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles