By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,579 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,579 IT Pros & Developers. It's quick & easy.

How to check if Mutex is set

P: n/a
Dear colleagues

I do the following:
Private Shared mutRefresh as New Mutex()

Before I call mutRefresh.ReleaseMutex() how can I check if
mutRefresh.WaitOne was called?

I realised that the I receive an exception if I call
mutRefresh.ReleaseMutex() before mutRefresh.WaitOne().

Hope somebody can help me.
Thanks Alex
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Alex,
Before I call mutRefresh.ReleaseMutex() how can I check if
mutRefresh.WaitOne was called? The routine that you are calling ReleaseMutex from should be the routine
that you called WaitOne from! So there should be no need to "check" if you
called WaitOne first.

Something like:

Private theMutex As New System.Threading.Mutex

Private Sub DoWork()
theMutex.WaitOne()
Try
' do work here
Finally
theMutex.ReleaseMutex()
End Try
End Sub

Calling WaitOne first, makes you the owner of the Mutext, ensuring that
noone else can own the "resource", calling ReleaseMutex releases you as the
owner of the Mutext.

Hope this helps
Jay
"Alex" <in********@gmx.ch> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Dear colleagues

I do the following:
Private Shared mutRefresh as New Mutex()

Before I call mutRefresh.ReleaseMutex() how can I check if
mutRefresh.WaitOne was called?

I realised that the I receive an exception if I call
mutRefresh.ReleaseMutex() before mutRefresh.WaitOne().

Hope somebody can help me.
Thanks Alex

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.