If I understood the question, you are trying to implement the locking in C# code.
To do this you can use a
Mutex[
^]
A simple usage would look like this, but please make sure you read the details and the article on MSDN about this, as mutex locking can lead to quite hard to find problems if you make a mistake.
class Example
{
private static Mutex m = new Mutex();
public static void DoSomething()
{
m.WaitOne();
m.ReleaseMutex();
}
}
If this was not what you were looking for, please clarify your question.