1.

How Do You Implement Thread Synchronization (object.wait, Notify,and Criticalsection) In C#?

Answer»

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);
}

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);
}



Discussion

No Comment Found