MethodImplOptions.Synchronized
的作用是什么?
下面是代码
[MethodImpl(MethodImplOptions.Synchronized)]
public void Method()
{
MethodImpl();
}
相当于
public void Method()
{
lock(this)
{
MethodImpl();
}
}
最佳答案
Mr. Jon Skeet 回答了这个问题在另一个site .
引自帖子
It's the equivalent to putting lock(this) round the whole method call.
该帖子有更多示例代码。
关于.net - MethodImplOptions.Synchronized 的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2223656/