c# - Starting up several programs at once -


I have written a small program (processed) to launch another program that is defined in .txt file ( new line ).

The code is mostly taken from MSDN. I am just starting my programming adventure but I want to write something useful.

I do not know how smart it is to run two programs simultaneously from my processesmemployment program.

In my .txt file, I have the path to the program with .exe. It is working fine but my program is running a program only at the time. I thought I would run forward, but of course it will not work here because it runs the first program and as long as I do not exclude it, then it waits, then it will run the next part.

So I know the reason why this is not working, I just want to know how I would like to work it.

My C # code:

  using the system; Using System.Diagnostics; Using System.Threading; Namespace process sample {class process monitor sample {public static zero main () {Console.BufferHeight = 25; // Define variables to track extreme memory usage of the process. Long peakWorkingSet = 0; String [] program = System.IO.File.ReadAllLines (@ "C: \ Programs \ list.txt"); Forchha (programming strings in the program) {Process myProcess = null; // Start the process MyProcess = Process.start (@program); // Display the process statistics until the user closes the program. Do {if (! MyProcess.HasExited) {// refresh the current process properties values ​​myProcess.Refresh (); // See the current process statistics Console.WriteLine (); Console.light line ("path: {0}, RAM: {1}", program, (MyPros.WorkingSet 64/1024/1024); // Update values ​​for aggregate extreme memory stats Peakkurset = myProcess.PakWorkingSet64; If (My process. Resending) {Console.WriteLine ("Status: Running"); } Else {Console.WriteLine ("Status: No Answer!"); } // Wait 2 seconds thread Sleep (2000); } // if} // do while (! MyProcess.WaitForExit (1000)); Console.WriteLine (); Console.light line ("Process Exit Code: {0}", myProcess.ExitCode); Console.lightline ("use of peak physical memory process: {0}", (peakwartingset / 1024/1024)); Console.light line ("press any key to exit."); System.Console.ReadKey (); } // foreach} // public} // class} // namespace    

interiors There is a problem in the loop where you are getting data from the process running and displaying them in the console. As far as I understand from your post, you do not need this feature, so you can remove it and you will get:

  using the system; Using System.Diagnostics; Using System.Threading; Namespace process sample {class process monitor sample {public static zero main () {Console.BufferHeight = 25; // Define variables to track extreme memory usage of the process. Long peakWorkingSet = 0; String [] program = System.IO.File.ReadAllLines (@ "C: \ Programs \ list.txt"); Forchha (programming strings in the program) {Process myProcess = null; // Start the process MyProcess = Process.start (@program); Console.light line ("program started: {0}", program); }}}}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -