Single Application Instance Example

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Jun 23 09:46:54 EDT 2005


[DeRRudi]
| 
| Whit this mutex is it possible when an instance is running in
| background and you try to open a new instance. you cancel it and show
| the first? 
| 
| Greetz

All the Mutex is doing is providing a single token
which only one instance of the app can hold at a
time. Of itself, it doesn't provide any facility to
awake background applications or do anything at all
except exclude other apps from holding the same
token.

What you describe could be achieved a number of ways.
(He says, sounding knowledegeable, but having little
real experience to back himself up). Once the Mutex 
check proves that you're not the only instance running, 
you could, for example, find the top-level window of your 
app and activate it (assuming it has a window). You could 
embed some sort of mini-messaging within the application, 
say a small Pyro class, or a socket server, or a Windows
pipe, or whatever, which will let your second instance
send a message to the first which will then activate
(whatever that means).

In fact, you could probably combine the two by using a 
private Windows pipe which would both serve as a "anyone
else here?" check and as a signal to an existing instance
to wake up and dance.

It all depends on what the app is doing, and how
hard you want to try.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list