I use this code to ensure only one application is running at one time.
In debug version, it runs ok
But, in release version, it failed. I don't why???
bool flgDouble ;
Mutex m = new Mutex( true, "App", out flgDouble);
if(flgDouble)
{
//Run Application
RunApp();
} 3 1919
Napo <Na**@discussions.microsoft.com> wrote: I use this code to ensure only one application is running at one time. In debug version, it runs ok But, in release version, it failed. I don't why??? bool flgDouble ; Mutex m = new Mutex( true, "App", out flgDouble); if(flgDouble) { //Run Application RunApp(); }
Chances are it's being garbage collected. Either stick it in a "using"
statement, or use a GC.KeepAlive(m); statement after your RunApp().
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
> > I use this code to ensure only one application is running at one time. In debug version, it runs ok But, in release version, it failed. I don't why??? bool flgDouble ; Mutex m = new Mutex( true, "App", out flgDouble); if(flgDouble) { //Run Application RunApp(); }
Chances are it's being garbage collected. Either stick it in a "using" statement, or use a GC.KeepAlive(m); statement after your RunApp().
But disposing it wouldn't let it stay alive, does it?
cody <de********@gmx.de> wrote: I use this code to ensure only one application is running at one time. In debug version, it runs ok But, in release version, it failed. I don't why??? bool flgDouble ; Mutex m = new Mutex( true, "App", out flgDouble); if(flgDouble) { //Run Application RunApp(); }
Chances are it's being garbage collected. Either stick it in a "using" statement, or use a GC.KeepAlive(m); statement after your RunApp().
But disposing it wouldn't let it stay alive, does it?
If you put the whole thing in a using statement, including the RunApp
part, then the Dispose call wouldn't happen until after the app had
run. Sorry if I wasn't clear.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: Napo |
last post by:
I use this code to ensure only one application is running at one time.
In debug version, it runs ok
But, in release version, it failed. I don't why???
bool flgDouble ;
Mutex m = new Mutex( true,...
|
by: Napo |
last post by:
I use this code to ensure only one application is running at one time.
In debug version, it runs ok
But, in release version, it failed. I don't why???
bool flgDouble ;
Mutex m = new Mutex( true,...
|
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...
|
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...
|
by: Andrew Rowley |
last post by:
I am having trouble getting debug and release builds to work properly
with project references using C++ .NET and Visual Studio 2003.
I created a test solution, with a basic Windows form C++...
|
by: =?Utf-8?B?Q2F2ZXk=?= |
last post by:
Hello,
Encountering a issue where I define a mutex to enforce a single instance of
an application. It works well under Debug but switching to release it fails
everytime..
bool exclusive =...
|
by: Lamont Sanford |
last post by:
Given an object of type Mutex, what method or property should be called to
determine if it is currently owned?
I could call WaitOne(0,false) -- and if the return value is false, I could
deduce...
|
by: Chris Forone |
last post by:
hello group,
is there a chance for other functions to get the lock if i have
following loop:
while (running)
{
Lock local(mutex);
}
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |