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.
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.