VS2005: Problem with System.Threading.Monitor

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I just tried to convert my current project to the new beta 2 of the .net
framework and I encountered some problems with my thread synchronization -
that formerly worked well.

When I release a monitor by System.Threading.Monitor(myvar) I receive the
following error message:

System.Threading.SynchronizationLockException: Object synchronization method
was called from an unsynchronized block of code.

Of course I acquired the Monitor some lines above by
System.Threading.Monitor.Enter(myvar).

can anyone help?

Thanks
Peter
 
Peter Schmitz said:
I just tried to convert my current project to the new beta 2 of the .net
framework and I encountered some problems with my thread synchronization -
that formerly worked well.

When I release a monitor by System.Threading.Monitor(myvar) I receive the
following error message:

System.Threading.SynchronizationLockException: Object synchronization method
was called from an unsynchronized block of code.

Of course I acquired the Monitor some lines above by
System.Threading.Monitor.Enter(myvar).

can anyone help?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

You could well have a bug in your code which is masked by another bug
in the framework - Monitor.Exit doesn't check whether or not the
monitor is currently owned in v1.1.
 
Back
Top