c# - Run single instance of an application using Mutex -
I'm using Mute X to allow only one instance of an ongoing application. Code is given below is the correct way to do this? Are there any flaws in the code?
When the user tries to open the application a second time, how to show an application that is already running. Currently (in the code below), I am displaying only one message which is another example Is already running.
Fixed zero main (string [] args) {mute x _mut = null; Try {_mut = Mutex.OpenExisting (AppDomain.CurrentDomain.FriendlyName); } Hold {// handler to be written} if (_mut == faucet) {_mut = new mutes (wrong, app domains.contentmonom.freeandlinnam); } And {_mut.Close (); MessageBox.Show ("Instance is already running"); }}
I did this once, I hope it helps Is:
Bull created new; Mute X = New Mute X (True, "My App", Created New); If (new! Created) {// myApp is already running ... MessageBox.Show ("MyApp is already running!", "Multiple instances"); Return; }
Comments
Post a Comment