Events and Timers
You used the Monitor class and its various methods to control data synchronization. Another way you could have achieved this is with the Event kernel object. Events were covered in Hour 18, “Delegates and Events,” but the events discussed here are operating system events. When an event is created, it is placed in a non-signaled state. You can then open the event within a different area of code, such as another thread. Once you obtain a handle to the event, you can then wait for it to be signaled. Once the event is signaled, the object waiting can then proceed.
Rather than restructuring the lesson you just created, you are just going to use events and a timer to simulate a long write operation. The code you are going to add will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access