2
Answers

Detect Open Instance and Show It

Pisi Can

Pisi Can

8y
292
1
Hi all!
 
I can check if the application is already running and show a message box that says "The app is already open, please double click on the system tray icon to show it". What I want is that when the user try to open the app again it shows the opened instance. How can I do that?
 
I check if the app is already open by the below codes:
 
string ProsesAdi = Process.GetCurrentProcess().ProcessName;
Process[] sonuc = Process.GetProcessesByName(ProsesAdi);
if (sonuc.Length > 1)
{
MessageBox.Show("Uygulama zaten açik. Sistem tepsisindeki simgeye çift tiklayin.", "Bilgi");
System.Environment.Exit(0);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
 
Answers (2)