c# Thread problem

J

Jon Skeet [C# MVP]

Thanks you guys... I was stupid ^^...
I could pull out update like follow, the code work well Thanks.. a
loooooooooooooooooot

<snip>

No, it's still not as good as it could be:

1) You should have *one* thread dequeuing things, not a new one every
time a message is added. The code you posted in the third post of the
thread had this correctly.

2) You're using Queue.Count outside the lock - again, this part was
correct in the older code.

In short, go back to the old code and just move the call to update to
outside the lock block.
 

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