Preventing Multiple Instance
I need to prevent the user from opening multiple instance of an application? If an instance is already running and if the user clicks on the exe icon i need to shift focus on the application which was opened?
Am able to display a MessageBox if there is already an instance running like:
Code:
if(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).GetUpperBound(0)>=1)
{
MessageBox.Show("An Instance of the application is already open.","Press Inventory Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Close();
}
Help me out?