locking on dictionary of structs not working between 2 threads?

Posted by Rancur3p1c on Stack Overflow See other posts from Stack Overflow or by Rancur3p1c
Published on 2011-01-13T04:56:06Z Indexed on 2011/01/13 5:53 UTC
Read the original article Hit count: 154

Filed under:
|
|

C#, .Net2.0, XP, Zen

I have 2 threads accessing a shared dictionary of structures, each thread via an event. At the beginning of the event I lock the dictionary, remove some structures, and exit the lock+event. Yet somehow the 2nd thread|event is finding some of the removed structures.

Conceptually I must be doing something wrong for this to be happening? I thought locking was supposed to make it thread safe?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET