From the course: Advanced Threading in C#

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Two-way signaling

Two-way signaling - C# Tutorial

From the course: Advanced Threading in C#

Start my 1-month free trial

Two-way signaling

- [Instructor] We just saw how to use an event wait handle of type auto reset event. Now, we're going to see how two-way signaling can work. It's very similar except this time, we will have a little bit more interaction between both the threads. So for example, main thread will be waiting while the worker thread will be updating a value and then it would release the main thread. And I will do the same exact thing by just reversing that order. So quite simply, we need to start with an event wait handle and resolve this using System.Threading. I'm just going to call it first, and this time we'll use the easy way out. Auto reset event and initial state is going to be false and that means it's not going to be signaled. And then we can create a similar one and we'll call this one second. Now this is where we can say Task.Factory.StartNew and start the worker thread. Again, this is a method and you call it something else. The reason I call it WorkerThread is so we know which thread is…

Contents