single-instance

Correct .NET way to implement a single instance application [closed]

怎甘沉沦 提交于 2019-11-30 01:23:12
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have seen at least three distinct methods on StackOverflow for achieving this. Using a MUTEX: Accepted answer to this SO question

How to enable only one instance of my application

坚强是说给别人听的谎言 提交于 2019-11-29 13:01:02
问题 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. I don't know how to solve this. 回答1: Use android:launchMode="singleTask" or android:launchMode="singleInstance" in your manifest.xml in your activity tag 来源: https://stackoverflow.com/questions/9467802/how-to-enable-only-one-instance-of-my

How to check if a WPF application is already running? [duplicate]

冷暖自知 提交于 2019-11-28 23:49:37
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. CharithJ [DllImport("user32.dll")] private static extern Boolean ShowWindow(IntPtr hWnd, Int32 nCmdShow); static void Main() { Process currentProcess = Process.GetCurrentProcess(); var runningProcess = (from process in Process.GetProcesses() where process.Id != currentProcess.Id && process.ProcessName.Equals( currentProcess.ProcessName, StringComparison.Ordinal) select

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

时光毁灭记忆、已成空白 提交于 2019-11-28 16:32:24
问题 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 application is running. If it is running, then I need the other instance to be made active. Usually, when selecting a Click Once link, the very first thing it does is attempt to find an update. I want to intercept this and check for an already running

Let gVim always run a single instance

拈花ヽ惹草 提交于 2019-11-28 16:21:19
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 gvim so that this becomes the default behavior. i.e. I want to type gvim filename and make it act as if I passed the --remote-tab-silent option to it. gVim 7.2 Edit I'm on windows (vista) dbr If you are using the bash shell (on Linux/OS X/using Cygwin) is to add you ~/.bashrc file: gvim () { command gvim --remote-silent "$@" || command gvim "$@"; }

Force multi-threaded VB.NET class to display results on a single form

邮差的信 提交于 2019-11-28 11:41:48
问题 I have a windows form application that uses a Shared class to house all of the common objects for the application. The settings class has a collection of objects that do things periodically, and then there's something of interest, they need to alert the main form and have it update. I'm currently doing this through Events on the objects, and when each object is created, I add an EventHandler to maps the event back to the form. However, I'm running into some trouble that suggests that these

How to run one instance of a c# WinForm application?

依然范特西╮ 提交于 2019-11-28 11:36:06
I've a C# application that displays a login form when launched and displays the main form after users are authenticated. I used Mutex to restrict that only one instance of my application runs. And, this works fine for only the Login form. Once the main form is displayed, it doesn't restrict users from reopening the Login form. I was looking for a solution by which the Login screen couldn't be displayed once the main form is already opened. Here is my Program.cs [STAThread] static void Main() { bool mutexCreated=true; using (Mutex mutex = new Mutex(true, "eCS", out mutexCreated)) { if

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

佐手、 提交于 2019-11-28 08:43:48
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 don't always have a main window) Create a mutex with a unique name (GUID) The mutex option seems to me the most reliable and elegant. However, before my second instance terminates, I want to post a message to the already running instance. For this, I need a handle to the thread (or the process) that owns the mutex. However, there seems to be no API

startActivityForResult not working properly with launchMode singleInstance

喜你入骨 提交于 2019-11-28 07:32:28
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 when another instance of that ListActivity is changed (added to, edited, removed from, etc) (or is there an easy way to do this?). Note: I've read that singleTop will accomplish this (though it destroys the Activity if you hit the back button), but it does not work. I have a menu and if I go to my Inbox screen, then I go to my QuickList screen, and

Run the current application as Single Instance and show the previous instance

半城伤御伤魂 提交于 2019-11-28 05:06:20
问题 I just implemented this code that is guarding the Single Instance of the Application, in order to not run the application twice. Now I am wondering how I can show the original Application process that is already running. Here is my code in the program class: static class Program { [STAThread] static void Main() { const string appName = "MyappName"; bool createdNew; mutex = new Mutex(true, appName, out createdNew); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault