c# - run outside application and track whether it's finished -
i have form allows users setup backup solution. option allow "force backup now" when clicking button. question is, app controls function console app, doesn't show console window. there way me start app , track it's status, give working screen , when it's done use messagebox relay completed status?
you maybe process.waitforexit().
this this msdn page on standard error.
// start child process. process p = new process(); // redirect error stream of child process. p.startinfo.useshellexecute = false; p.startinfo.redirectstandarderror = true; p.startinfo.filename = "backupprogram.exe"; p.start(); //you read standard error backup program //incase went wrong.. string error = p.standarderror.readtoend(); //warning thread block on method. p.waitforexit(); notes:
if have windows forms application need handle blocking correctly. if call waitforexit() on main thread application going hang up.
i don't think can show status directly. unless code backup program communicate main program.
so use background worker or async programming implement run , wait , show indeterminate progress status. (progressbar1.style = progressbarstyle.marquee)
Comments
Post a Comment