What does MethodImplOptions.Synchronized do?

What does MethodImplOptions.Synchronized do?

Is the code below

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

equivalent to

public void Method()
{
    lock(this)
    {
        MethodImpl();
    }
}

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.


For static methods it's the same as:

public class MyClass
{
    public static void Method()
    {
        lock(typeof(MyClass))
        {
           MethodImpl();
        }
    }
}

http://social.msdn.microsoft.com/Forums/en-US/b6a72e00-d4cc-4f29-a6a0-b27551f78b9b/methodimploptionssynchronized-vs-lock


Yes it is. See MethodImplOptions Enumeration