0

i am looking for a method that i can't find anywhere, maybe i'm unable to search, i wish my single instance executable can be reopened by reopening its executable, let me explain better. I open the executable, the form hides, I re-open the exe and the form of the first executable returns to me without opening another instance, I hope I made myself understood

i have this code in mainwindow.iniz...

Process[] Processes = Process.GetProcesses();
        int Count = 0;

        foreach (Process Proc in Processes)
        {
            if (Process.GetCurrentProcess().ProcessName == Proc.ProcessName)
            {
                Count++;
            }
        }
        if (Count > 1)
        {
            Process.GetCurrentProcess().Kill();
        }
  • Specify the platform: `WPF`, `WinForms`. `mainwindow` may suggest WPF, but you also call it *Form*, so... – Jimi Sep 19 '20 at 16:09
  • sorry , wpf. I have edited the title – Alessio Ricci Sep 19 '20 at 16:11
  • 1
    [What is the correct way to create a single-instance WPF application?](https://stackoverflow.com/a/19326/7444103). You dont't have to change the question's Title, you have to tag the question. Remove `windows` which is unrelated and add `wpf`. – Jimi Sep 19 '20 at 16:19

0 Answers0