C# preventing more than one application instance at a time

C# preventing more than one application instance at a time

//check if previous instance of the application is already running

//get the name of our process

string proc = Process.GetCurrentProcess().ProcessName;//Get the list of all processes by that name

Process[] processes = Process.GetProcessesByName(proc);//if there is more than one process

if (processes.Length > 1)

{

MessageBox.Show(”A previous instance of the application is already running”);

return;

}

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.