using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BringToFrontLab
public static class Program
public static void Main()
using (Mutex mutex = new Mutex(false, "Form1"))
if (!mutex.WaitOne(0, true))
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("USER32.DLL")]
public static extern bool ShowWindow(IntPtr hWnd,int i);
public static void bringToFront(string title)
IntPtr handle = FindWindow(null, title);
if (handle == IntPtr.Zero)
SetForegroundWindow(handle);
public class Form1 : Form { }