what happens if pulse is invoked before wait?

A

Andy Fish

Hi,

I'm using the Monitor class to perform some simple synchronization between
threads. In the documentation for pulse it says:

"The remarks for Wait(Object, Int32) address an issue that arises when Pulse
is invoked before Wait."

I can't find any reference to this issue anywhere. Can someone enlighten me
as to the nature of it?

TIA

Andy
 
J

Jon Skeet [C# MVP]

Andy Fish said:
I'm using the Monitor class to perform some simple synchronization between
threads. In the documentation for pulse it says:

"The remarks for Wait(Object, Int32) address an issue that arises when Pulse
is invoked before Wait."

I can't find any reference to this issue anywhere. Can someone enlighten me
as to the nature of it?

Effectively, any Pulse or PulseAll which is called when no thread is
waiting on the monitor is a no-op. A monitor is *not* a counting
semaphore (although it can be used to build one).
 
A

Andy Fish

Jon Skeet said:
Effectively, any Pulse or PulseAll which is called when no thread is
waiting on the monitor is a no-op. A monitor is *not* a counting
semaphore (although it can be used to build one).

Ok, thanks John. That's the behaviour I was expecting (infact relying on)
anyway.
 

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