6
Answers

Problem with closing other instances of my application

Mick Negendahl

Mick Negendahl

12y
1.2k
1
Hi guys!

I need my program to close old instances of it, when a new one comes up. I did my code like this:

public void killInstance()
  {
  Process[] Denlillehjaelper;
  Denlillehjaelper = Process.GetProcessesByName("Den lille hjælper"); 
  foreach (Process MyProcess in Denlillehjaelper)
  {


  MyProcess.CloseMainWindow();
  MyProcess.Close();
 
  }
 
  }


And I call this from later in my code.

I can see it accurately runs this piece of code (i did a messagebox.show - just to check) but it dosent close the old instances of my application.

Maybe someone could help me? :)


Answers (6)