Re: prevent multiple instances of a program
Re: prevent multiple instances of a program
- Subject: Re: prevent multiple instances of a program
- From: Dave DeLong <email@hidden>
- Date: Wed, 11 May 2011 14:04:45 -0700
There are a bunch of ways to do this, but the general principle is that when an instance of the app starts, it makes its presence known somehow (touching a file, broadcasting a distributed notification, vending a distributed object, etc). Then when a second instance starts, it tries to find a previous instance (looking for the file, broadcasting a distributed notification and waiting for a response, connecting to a distributed object, etc). If it finds one, it kills itself.
Dave
On May 11, 2011, at 2:02 PM, Martin Batholdy wrote:
> Hi,
>
> My program consists of a menu item and is NSUIagent - so it is hidden in the Mac OS app-bar.
>
> Now what surprises me is that I am able to open several instances of this program.
> Every time I click on the app-file a new symbol appears and I have a new instance of my program running.
>
> How can I prevent this?
> (so that system-wide you can only have one instance of the program running)
>
> Is there a build-option in xCode for this?
>
>
> thanks!_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden