Sign in to follow this  
Penance

[.net] Monitor Warning

Recommended Posts

Just FYI in 2.0 Monitor.Exit() calls are checked to ensure that the thread calling Exit owns the lock to begin with. I had a sinister little bug where I was locking a string variable and setting it to String.Empty in one part of my code. I was throwing exceptions in 2.0 but not 1.1 and it was becase String.Empty is of course a separate, static object. So in some cases I actually didn't own the lock on my String variable, even though just looking at the code made it seem like I did. Fixed the problem by using a separate empty Object for locking.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this