Quick Mutex Question

  • Thread starter Thread starter dln
  • Start date Start date
D

dln

If I were to use the following call:

Mutex my_mutex = new Mutex();
bool got_lock = my_mutex.WaitOne(500, false);

and then got_lock returns false, do I need to call "my_mutex.ReleaseMutex()"
on it? So put another way, should I always call ReleaseMutex, regardless of
whether or not I got the lock?

Thanks.
 
dln said:
If I were to use the following call:

Mutex my_mutex = new Mutex();
bool got_lock = my_mutex.WaitOne(500, false);

and then got_lock returns false, do I need to call "my_mutex.ReleaseMutex()"
on it? So put another way, should I always call ReleaseMutex, regardless of
whether or not I got the lock?

No - if you didn't acquire it, you shouldn't release it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top