What does MethodImplOptions.Synchronized do?

Viewed 28078

What does MethodImplOptions.Synchronized do?

Is the code below

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

equivalent to

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

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.

Related