I'd like to Run Code on Application Exit. My Problem is that I have two Application. The First is running. My Second Application now is going to Close the First Application. But on Closing I'd like to run code in the First Application.
public class First
{
public static Main(string[] args)
{
Console.ReadLine();
}
public void DoSomethingOnExit()
{
Console.WriteLine("It Works");
Thread.Sleep(1000);
}
}
public class Second
{
public void method(int number)
{
var prozess = Process.GetProcessById(number);
prozess.Close();
}
}