C# (Sharp) Programming Language Question:
Download Questions PDF

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


Download C# (Sharp) Programming Language Interview Questions And Answers PDF

Previous QuestionNext Question
How do you mark a method obsolete? How do you directly call a native function exported from a DLL?