What is the fastest way to run an exe command many times in C#? -


my code (written in c#) runs exe command many times (800 times average).

currently run exe command process in c#:

  var process1 = new process()   {       startinfo = new processstartinfo()       {           filename = "latex",           arguments = string.format("-quiet -output-directory=\"{0}\" \"{1}\"", equationdirectory, equationtex),           workingdirectory = equationdirectory,           createnowindow = true,           useshellexecute = false,           redirectstandarderror = true,           redirectstandardoutput = true       }   };   process1.start(); 

this taking time, of windows starting shell process.

question wondering if faster embed exe in code , run it? fastest way run executable many times (in loop let say)?

it may running them @ once forces them compete resources, example - using system memory, causing paging hdd.

maybe using below, , testing number can run concurrently, you'll find sweet-spot:

var processes = new list<process>();  var process1 = new process() {     startinfo = new processstartinfo()     {         filename = "latex",         arguments = string.format("-quiet -output-directory=\"{0}\" \"{1}\"", equationdirectory, equationtex),         workingdirectory = equationdirectory,         createnowindow = true,         useshellexecute = false,         redirectstandarderror = true,         redirectstandardoutput = true     } };  //add of processes list before running them processes.add(process1);  //this run 5 in parallel parallel.foreach(processes, new paralleloptions { maxdegreeofparallelism = 5 }, p => { p.waitforexit(); }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -