0
hi kiran i need your this code can you help me
0
i'm trying to use your code but i'm getting an error in below line that says 'System.Threading.Mutex' does not contain a constructor that takes '3' arguments
Mutex m = new Mutex(true, MutexName, out WasCreated);
do u have any idea why i'm i getting this error.
Thank you,
0
If you only need to detect a previous instance, then a
Mutex is easy and effective. I am not sure you can do this with Windows Mobile, but probably you can. Note that you should place this code in the Program.cs
file, not in the Form class. Put this code just before the line that says "
Application.Run(new Form1());" or something such as that.
bool WasCreated;
const string MutexName = "Project_76468";
Mutex m = new Mutex(true, MutexName, out WasCreated);
if (!WasCreated)
{
// MessageBox.Show("A previous instance exists");
return;
}
Also, after the "
Application.Run(new Form1());" you need to also do the following :
GC.KeepAlive(m);
That line is not important for small programs, but always use it anyway when using the above code that uses the Mutex.