Questions tagged [single-instance]

Make sure that only one instance of the application is running on the system.

250 questions
93
votes
17 answers

How to implement a single instance Java application?

Sometime I see many application such as msn, windows media player etc that are single instance applications (when user executes while application is running a new application instance will not created). In C#, I use Mutex class for this but I don't…
Fuangwith S.
  • 5,654
  • 8
  • 37
  • 41
63
votes
15 answers

How to create a single instance application in C or C++

What would be your suggestion in order to create a single instance application, so that only one process is allowed to run at a time? File lock, mutex or what?
whoi
  • 3,281
  • 7
  • 36
  • 44
47
votes
11 answers

Is using a Mutex to prevent multiple instances of the same program from running safe?

I'm using this code to prevent a second instance of my program from running at the same time, is it safe? Mutex appSingleton = new System.Threading.Mutex(false, "MyAppSingleInstnceMutx"); if (appSingleton.WaitOne(0, false)) { …
Malfist
  • 31,179
  • 61
  • 182
  • 269
39
votes
13 answers

Let gVim always run a single instance

Is there a way to let gVim only run a single instance, so that when a new file is opened with it it's automatically opened in a new tab in the currently running instance? I know you can do that by passing --remote-tab-silent but I want to configure…
hasen
  • 161,647
  • 65
  • 194
  • 231
36
votes
12 answers

Ensure a single instance of an application in Linux

I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense,…
Matt Green
  • 2,032
  • 2
  • 22
  • 36
29
votes
6 answers

onActivityResult do not fire if launch mode of activity is singleInstance

I have an Activity which is basically my main activity and its launch mode is single instance. But because of singleInstance, the onActivityResult() callback does not fire. And if I change the launch mode in my manifest file to any other mode it…
sajjoo
  • 6,576
  • 20
  • 65
  • 86
18
votes
2 answers

startActivityForResult not working properly with launchMode singleInstance

I'd like Activities on my application's Activity stack to only have one instance. I have several screens which are ListActivities and I'd like to not go through the pain and suffering of updating the lists in a previous instance of the ListActivity…
Andrew
  • 281
  • 1
  • 4
  • 10
17
votes
1 answer

Ensuring that only a single instance of a nodejs application is running

Is there an elegant way to ensure that only one instance of a nodejs app is running? I tried to use pidlock npm, however, it seems that it works only on *nix systems. Is it possible by using mutex? Thanks
Ron Yadgar
  • 387
  • 4
  • 11
17
votes
3 answers

Correct .NET way to implement a single instance application

I have seen at least three distinct methods on StackOverflow for achieving this. Using a MUTEX: Accepted answer to this SO question Using the Microsoft.VisualBasic library's WindowsFormsApplicationBase: Second highest voted answer to this SO…
Michael Mankus
  • 4,628
  • 9
  • 37
  • 63
15
votes
4 answers

How can I build a single instance application using Click Once?

I need to have a single instance application (as per this answer), but it needs to be deployed via click once. The problem is that I require that click once doesn't automatically detect an update an attempt to load a newer version while the…
Ben Laan
  • 2,607
  • 3
  • 29
  • 30
14
votes
1 answer

How to enable only one instance of my application

I need only one instance of my app in android. If I run my app after installation and go to Home screen, and again run my app (click on app's icon), second instance is opened, I need to open already running first instance not to run second instance.…
Palejandro
  • 2,092
  • 5
  • 26
  • 38
11
votes
2 answers

Getting Permission error java.lang.SecurityException: Permission Denial on 3.x Android devices while getting email attachment name

I am facing issue in opening Email in MYApp when I made its launch mode to "singleInstance". I have attached sample Android project which reads file name from email attachment and displays it on screen. Works fine in case of onCreate but throws…
tumbudu
  • 699
  • 11
  • 26
11
votes
2 answers

When should I use lazy Singletons over normal Singletons?

So far I have seen two examples of Singletons. Normal Singletons, public class Singleton { private static Singleton instance; static { instance = new Singleton(); } private Singleton() { // hidden constructor } public…
VeeAyeInIn
  • 193
  • 1
  • 12
11
votes
6 answers

Win32: How to get the process/thread that owns a mutex?

I'm working an application of which only one instance must exist at any given time. There are several possibilities to accomplish this: Check running processes for one matching our EXE's name (unreliable) Find the main window (unreliable, and I…
Thomas
  • 174,939
  • 50
  • 355
  • 478
10
votes
4 answers

How to check if a WPF application is already running?

Possible Duplicate: What is the correct way to create a single instance application? How can I check if my application is already open? If my application is already running, I want to show it instead of opening a new instance.
Irakli Lekishvili
  • 33,492
  • 33
  • 111
  • 169
1
2 3
16 17