As you can see in this answer https://stackoverflow.com/a/39704027/6886308 ,you can tell when an winform was closed like in the example ,the Notepad
.
And I tried playing with it a bit and while the code in the example worked ,something bothered me.
What if I want to close my app when the Notepad
was closed?So I tried something like:
void watcher_EventArrived(object sender, EventArrivedEventArgs e)
{
if ((string)e.NewEvent["ProcessName"] == "notepad.exe")
{
Close();
}
}
And it is trowing me an un-handled error ,so I was thinking maybe the focus remained on the winform?Or what is the problem in fact?