The following code illustrates how to check if previous instance of the application is running
using System.Diagnostics;
public void CheckForExistingInstance()
{
Process process = Process.GetCurrentProcess();
if (Process.GetProcessesByName(process.ProcessName).Length > 1)
{
MessageBox.Show("Another Instance of this process is already Running",
"Multiple Instance Forbidden", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Exit();
}
}
No comments:
Post a Comment