Mick Negendahl

Mick Negendahl

  • NA
  • 7
  • 1.5k

Problem with closing other instances of my application

Feb 8 2012 5:38 AM
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)