Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you confine to one instance?

Status
Not open for further replies.

crvoss

Programmer
May 2, 2005
21
US
I have written a tcl app which launches a secondary app and it is important that there be only one instance of the secondary app. Currently I am using the following to launch the secondary app:
.mnuBar.mnuUtil add command \
-label "Calc Room Sound" -command {
open "| wish.exe c:/TclFS/RoomSound.tcl"
}

If I select the menu item again I have two instances of RoomSound.tcl running. This is what I want to avoid.

What is the solution?
 
The only way I can suggest is to set a flag and launch on the flag condition, setting the flag in the process.
By the way, why are you running your launched script in another shell, rather than using "source"?

_________________
Bob Rashkin
rrashkin@csc.com
 
My fault -- the secondary application can be launched from several others but there should be only one instance of it. If I set a flag in one app the other apps will not be aware and will launch their own copy (a bad deal). There are several secondary apps that need the same restraints. None the less your reply gave me an idea -- there is an underlying database and each of the secondary apps can have a flag in the database that is set when launched. Oops -- if they crash or something without un-setting the flag I'm in trouble. Hmmm!

I am running a second wish because I want the secondary app to remain available when I close the original app -- but I see that it does not work that way. Another problem!!! Help!
 
Have the launched app create a specially named file, then have all the potential launchers check for that files existence, then have the launched app delete the file when it exits?

_________________
Bob Rashkin
rrashkin@csc.com
 
Doesn't that have the same problem as the database in that if the secondary app crashes without the flag/file being deleted then the secondary app cannot be launched thereafter (or at least until somebody manually deletes the flag/file)?
 
Yes it does. Maybe you can do something with a socket. Have the secondary app open a server socket and the primary app can check for the existence of the socket. Then if the secondary app crashes, the socket should go with it.

_________________
Bob Rashkin
rrashkin@csc.com
 
Hey!! That may be it! I have never done sockets before so may need help with it. As I understand it, when a secondary app is launched it will become the socket server. Any time any one of the app that can potentially launch the secondary app does attempt to launch a duplicate of the secondary app they first test the appropriate socket. If the socket connects then the duplicate secondary app is not launch (with a dialog informing the user of such). If the socket fails then the secondary app is launched. Thanks a bunch -- I'll give that a shot. Stay tuned though. Like I said, I have never done sockets so may need some help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top