First of all, I'm programming in Windows Forms Application.
As the title describes, I want to perform an action when a process I started, will close.
I've tried at first:
Process s = new Process();
s.EnableRaisingEvents = true;
s = Process.Start(processToStart);
s.Exited += s_Exited;
When I do:
Process s = new Process();
s = Process.Start(processToStart);
s.EnableRaisingEvents = true;
s.Exited += s_Exited;
I get exception of System.InvalidOperationException.
Full exception details:
Additional information: Cross-thread operation not valid: Control 'Main' accessed from a thread other than the thread it was created on.