marc wellman
marc wellman

Reputation: 5886

Firing events and sleeping threads

Does the blocking of a thread also blocks the firing and/or propagation of event fired from it?

To clarify:

On a thread I am firing an event and as a next step I let the thread fall asleep. The question is whether the firing - if stated immediately before the statement to go sleep - is also blocked to fire due to a scheduling issue (i.e. the event has been scheduled to fire but actual firing will take place in say 100 ms and before these 100 ms have been passed the thread has been fall asleep).

// Pseudo-Code

event MyHandler TheEvent;

// ...

TheEvent();
threadWaitingSignal.Wait(); // block the thread

What assumptions can I make in the above scenario regarding the firing and the delivery of the event to its subscribers ?

Upvotes: 0

Views: 235

Answers (1)

Richard Schneider
Richard Schneider

Reputation: 35477

All listeners will receive the event before the thread sleeps. Events are fired synchronously.

Upvotes: 4

Related Questions