Skip to content

Instantly share code, notes, and snippets.

@sailfish009
Created January 29, 2019 02:47
Show Gist options
  • Save sailfish009/8faf0e5153ae8704416ec3e21fdb6cc0 to your computer and use it in GitHub Desktop.
Save sailfish009/8faf0e5153ae8704416ec3e21fdb6cc0 to your computer and use it in GitHub Desktop.
using System.Diagnostics;
namespace Server
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Process[] p = Process.GetProcessesByName("yourApp");
if (p.Length > 1)
{
MessageBox.Show("app is already running!",
"app running",
MessageBoxButtons.OK,
MessageBoxIcon.Hand);
// p[1].Kill();
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment