views:

35

answers:

2

Is the code below

[MethodImpl(MethodImplOptions.Synchronized)]
public void Method()
{
   MethodImpl();
}

same as

public void Method()
{
   lock(this)
    {
       MethodImpl();
    }
}
+1  A: 

This was answered by Mr. Jon Skeet on another site.

Quote from Post

It's the equivalent to putting lock(this) round the whole method call.

The post has more example code.

David Basarab
A: 

Yes it is. See MethodImplOptions Enumeration

Michael Stoll