Tuesday, February 08, 2005

Synchronization in .NET

The MethodImplAttribute Class

System.Runtime.CompilerServices namespace contains attributes that affect the runtime behaviour of the CLR. MethodImplAttribute notifies the CLR on how the method is implemented. One of its constructors accesp the MethodImplOptions enumeration as a parameter. The MethodImplOptions enumeration has a field named Synchronized that specifies that only one thread is allowed to access this method at any one time.

This is done by doing this:
[MethodImpl(MethodImplOptions.Synchronized)]
public void doThis() { ... }




0 Comments:

Post a Comment

<< Home