I am trying to make sure only one instance of my application is running at one time. This code does not work. The Length is always 0. Does anyone know how to accomplish this task?
if(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1)
{
MessageBox.Show("Message Board Is Already Running","Message Board",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
this.Close();
}
if(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1)
{
MessageBox.Show("Message Board Is Already Running","Message Board",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
this.Close();
}