|
-
June 23rd, 2004, 02:37 PM
#1
How to running an application just one instance at time?
Hello.
I need to run a windows console application (.NET, C#), but avoidding the execution another instance of the same application at same time.
How to do that?
Last edited by hlancelot; June 23rd, 2004 at 02:39 PM.
-
June 24th, 2004, 02:31 PM
#2
Use System.Process to see if a process from the same executable file exist
-
June 24th, 2004, 02:43 PM
#3
Hallo,
try to resolve your problem with this, maybe it'll help you.
r.
try
{
bool firstInstance = false;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out firstInstance);
if(!firstInstance)
{
MessageBox.Show("You cannot run application twice.","Information");
return;
}
Application.Run(new TableForm ());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
-
June 25th, 2004, 07:56 AM
#4
Thank you very much!
The mutex solution works perfectly!
-
July 7th, 2005, 05:44 AM
#5
Re: How to running an application just one instance at time?
I have problem with the above code when running application in release mode?
The firstInstance seems to be true all the time.
Anyone having simular problems?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|