A very easy kind of event you can wait for is the ManualResetEvent
, and even better, the ManualResetEventSlim
.
They have a WaitOne()
method that does exactly that. You can wait forever, or set a timeout, or a "cancellation token" which is a way for you to decide to stop waiting for the event (if you want to cancel your work, or your app is asked to exit).
You fire them calling Set()
.
Here is the doc.