0

At the end of my c# console program, I have made a M file which graph a function in MATLAB, and run it this way:

System.Diagnostics.Process Mfile = new System.Diagnostics.Process();
Mfile.StartInfo.FileName = "M.m";
Mfile.Start();

Is there any way to write a code that when user closes that MATLAB window, a txt file opens? I can open both files together but I'm really interested to know if it is possible to understand when user closes that MATLAB file.

bunNyBug
  • 146
  • 1
  • 2
  • 13

2 Answers2

1

Process.WaitForExit is somewhat in the ballpark, but what you want is an event.

You can use Process.Exited to invoke a method once the process is closed.

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exited.aspx

The Muffin Man
  • 19,585
  • 30
  • 119
  • 191
0

Check out Process.WaitForExit method. As documentation says it should wait for the process you will transfer. The using should be like

Mfile.WaitForExit();
// here you can invoke Notepad.exe with your text file
Blablablaster
  • 3,238
  • 3
  • 31
  • 33