c# - Windows Forms - Repeatedly Running an External Process -


i have small windows forms application needs able run external application unlimited number of times without closing application after each run.

the external application runs single instance , resource hungry , slow load. basic workflow follows:

1: wait trigger load external app 2: trigger raised, open external app command line reference 3: monitor log file 3: external app processes command line data , writes log file 4: log file changed, send next command line (already open) external app 5: go step 3

the problem have cannot find way of loading external application without first closing/killing process.

applicationprocess.startinfo.filename = commandline; applicationprocess.start();  // watch change in log file , then... applicationprocess.startinfo.filename = commandline; applicationprocess.start(); 

and on, if don't

applicationprocess.kill(); 

before re-issue applicationprocess.start() method thread exception.

i think need disconnect applicationprocess once has started, cannot find mechanism this.

any advice/direction appreciated.

thanks.

if intend launch new instance of external application, allocate new process() object. create 1 process() object each time launch external application, rather trying re-use original one.

if intend manipulate existing instance of external application, 1 launched, don't need call start() again, continue using applicationprocess.


Comments