what happens if pulse is invoked before wait?

  • Thread starter Thread starter Andy Fish
  • Start date Start date
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
 
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).
 
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.
 
Back
Top