473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to check if Mutex is set

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
1 1562
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
5
by: Ken Varn | last post by:
I have a named mutex object that is accessed by both an asp.net application and a Windows executable .net application. The Windows executable runs under the administrator logon, while the asp.net...
2
by: Ken Durden | last post by:
I'm setting up an interface where clients must perform external locking before calling certain commands. I do this to force them to specify the duration the action they performed must persist...
2
by: Martin Maat | last post by:
Hi. I want to use the same mutex in different classes (web pages in an ASP.NET application). In global.asax.cs, the class that starts up first, I create a Mutex like this: static private...
16
by: Ed Sutton | last post by:
I use a mutex to disallow starting a second application instance. This did not work in a release build until I made it static member of my MainForm class. In a debug build, first instance got...
2
by: tony.newsgrps | last post by:
Hi there, I'm trying to understand the impact of killing a process that owns a system mutex (used to ensure there is only 1 instance of my program running) Here is my code pretty much: try...
14
by: Alex K. | last post by:
Hi all I'd like to avoid starting the same c# application twice on the same computer. How do I check if it is already running? Thank you
4
by: =?Utf-8?B?Um9i?= | last post by:
What is the C# command/function for checking to see if another instance of the application is already running?
3
by: NaeiKinDus | last post by:
Hello, i'm trying to program a thread that would be locked (by a mutex) and that would only be unlocked once that a function (generating data) is done. The purpose is to generate data, and unlock...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.