开发者

.NET DynamicMethod Thread Safe?

If I write a DynamicMethod with an ILGenerator and the code that I output is thread safe would the resulting delegate be threadsafe?

My concern is that the IL gets compiled the first time the method runs. If that is true what happens if some other thread tries to run the delegat开发者_C百科e while it is compiling?


It doesn't do any difference with a standard delegate. They are both present as MSIL somewhere and the JIT compile them when it wants.

Once you have it in delegate form it is a body of code you could call. That's all you really need to know. The implementation of .NET you are running in (Rotor, Mono, Microsoft one) should shield you from any consideration about this, otherwise it's a bug in the implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜