• Advertisement
Sign in to follow this  

Mutex Question

This topic is 4324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to use a mutex and I'm programming in .net. I learned how to use a mutex on a linux box and it doesnt look like my knowledge carries over to a windows box. Im curious if there is a preferred mutex class in windows? (that is if there even is a variety of mutex) thanks for ur help

Share this post


Link to post
Share on other sites
Advertisement
In windows you can use
CreateMutex() to make a mutex
WaitForSingleObject() to lock a mutex
ReleaseMutex() to release the mutex
(edit note) Missed .net, just saw "windows". These functions are the the old Win32 API calls, not .net. :(
The overall program structure should be no different from what you would do in linux.

You could also download the pthread libraries, and have the same POSIX standard threads from linux in your windows programs.

Share this post


Link to post
Share on other sites
If you are using .Net then you can look at the System.Threading.Mutex class, however if you don't need to share it across processes then you can simply use the Monitor class to perform synchronization (lock(){} construct C#).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement