From the course: 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.

Mutex

Mutex - C# Tutorial

From the course: Threading in C#

Start my 1-month free trial

Mutex

- [Instructor] Let's create a new project to see how a Mutex works. We're going to create a static Mutex. We might have to resolve the reference using system dot threading, and then we'll call it Mutex. We'll say new Mutex. Now there are a couple of options here. For example, the first one, you could say it's false, so once you say it's false, means the thread that's actually creating the instance for the Mutex class will not have ownership of that Mutex. Now if say true, that means the thread, which is the UI thread in this case, will already acquire the Mutex before anyone else gets it. Now if you don't pass any value whatsoever, it still considers it false, so by default, it's false. We can also give a name to the Mutex. Once you provide a name to the Mutex, that name is computer-wide. You can actually search that Mutex with that particular name. So that's another thing to keep in mind. We could have come here and said, just call it whatever you want to call it, let's say Cazton is…

Contents