c# 4.0 - Send/wait/receive data from CLI app through C# GUI app on VS 2010 -
i have .exe when opened looks this:
- enter a: (waits input a)
- enter b: (wait input b once entered)
- doing calculations..
- almost done..
- the sum of + b 10
- press enter exit..
i've written code based on other examples on stackoverflow (c# gui app on vs 2010):
processstartinfo cmdstartinfo = new processstartinfo(); cmdstartinfo.filename = @"c:\mytestservice.exe"; cmdstartinfo.redirectstandardoutput = true; cmdstartinfo.redirectstandarderror = true; cmdstartinfo.redirectstandardinput = true; cmdstartinfo.useshellexecute = false; cmdstartinfo.createnowindow = false; process cmdprocess = new process(); cmdprocess.startinfo = cmdstartinfo; cmdprocess.errordatareceived += cmd_error; cmdprocess.outputdatareceived += cmd_datareceived; cmdprocess.enableraisingevents = true; cmdprocess.start(); cmdprocess.beginoutputreadline(); cmdprocess.beginerrorreadline(); cmdprocess.standardinput.writeline(textbox1.text); cmdprocess.standardinput.writeline(textbox2.text); static void cmd_datareceived(object sender, datareceivedeventargs e) { messagebox.show("output other process: " + e.data); } static void cmd_error(object sender, datareceivedeventargs e) { messagebox.show("error other process: " + e.data); }
i passing , b through values entered in 2 textboxes apparently that's not working properly. how i:
- enter , wait
- once entered, enter b , wait
- when console app returns "the sum of + b 10" how value 10?
- how send enter parameter force app close?
thanks!
Comments
Post a Comment