MethodImplOptions

D

Dan Avni

Does the MethodImpl attribute work on the .Net CF 2.0 (VS 2005)? I'm using
the following method attribute to synchronize access to a method but it does
not appear to be working.

<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.Synchronized)>
_
 
D

Daniel Moth

You are right, it isn't working.

While the metadata gets generated correctly (synchronized on the method),
the runtime clearly ignores that.

As an alternative, wrap you method body with
lock (this) // better even, some other object
{
}

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top