single-instance

onActivityResult do not fire if launch mode of activity is singleInstance

纵饮孤独 提交于 2019-11-26 15:53:58
问题 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 works fine. Can you explain why this callback is not working? 回答1: I believe that the problem is that singleInstance doesn't let the callee activity to exist in the same task as the caller, hence it can't return the value to the caller. Consider using

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

江枫思渺然 提交于 2019-11-26 11:42:39
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)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); appSingleton.Close(); } else { MessageBox.Show("Sorry, only one instance of MyApp is allowed."); } I'm worried that if something throws an exception and the app crashes that the Mutex will still be held. Is that true? JaredPar In general yes this will

Ensure a single instance of an application in Linux

不打扰是莪最后的温柔 提交于 2019-11-26 04:36:34
问题 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, and will fail quickly. Under Win32, I can simply make a named mutex and check that at startup. Unfortunately, I don\'t know of any facilities in Linux that can do this. I\'m looking for something that will automatically be released should the

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

大兔子大兔子 提交于 2019-11-26 02:32:42
问题 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)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); appSingleton.Close(); } else { MessageBox.Show(\"Sorry, only one instance of MyApp is allowed.\"); } I\'m worried that if something throws an

How to implement a single instance Java application?

别来无恙 提交于 2019-11-25 22:38:03
问题 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 know how to do this in Java. 回答1: If I believe this article, by : having the first instance attempt to open a listening socket on the localhost interface. If it's able to open the socket, it is assumed that this is the first instance of the