MethodImplOptions

  • Thread starter Thread starter Dan Avni
  • Start date Start date
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)>
_
 
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
 
Back
Top