C# (Sharp) Programming Language Question:
Download Job Interview Questions and Answers 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);
}
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 Question | Next Question |
How do you mark a method obsolete? | How do you directly call a native function exported from a DLL? |