static
void
Main()
![](https://i-blog.csdnimg.cn/blog_migrate/6be2cd829904b1567ba3a8dd21b560f2.gif)
{
// 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![](https://i-blog.csdnimg.cn/blog_migrate/6f84e603aa6f75522d994c552fdc433d.gif)
if (processes.Length > 1)
![](https://i-blog.csdnimg.cn/blog_migrate/896a732e36cc052bec877098e990374d.gif)
{
MessageBox.Show("Application is already running");
return;
} else
Application.Run(new Form1());
}
![](https://i-blog.csdnimg.cn/blog_migrate/6be2cd829904b1567ba3a8dd21b560f2.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/66949df97b9d394d52e6f77a0fe5ece3.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6f84e603aa6f75522d994c552fdc433d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6f84e603aa6f75522d994c552fdc433d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/896a732e36cc052bec877098e990374d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ba30943ca2f9ddae913d881ea94137c.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6f84e603aa6f75522d994c552fdc433d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/bca08b7956d4470f4500a0ab853529f5.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/120ce0da914894d58238e9ab2f3f286d.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/c08f68467f78516caf58d67cb4613601.gif)