c# - How to know the exe run by my application's process has completed its work -


i have got 2 exe (console)

first exe provides facility convert video formats. second exe provides facility split video.

in application have got 2 buttons both process working fine separately. wants make work on single click. means first should convert video using first exe , split using second exe.

the problem how find first exe has finished work can start second exe work on output's of first exe.

i running both exe creating process.

note: both exe gets close when done work, may can check existing of there process wants experts opinion this.

thanks

if using gui, halt if use waitforexit.
here's asynchronous example. have adapt needs:

using system; using system.diagnostics; using system.componentmodel; using system.threading;  class converterclass {     private process myprocess = new process();     private bool finishedflag = false;      /* converts video asynchronously */     public void convertvideo(string filename)     {         try         {             /* start process */              myprocess.startinfo.filename = "convert.exe"; /* change */             /* if convert.exe app accepts 1 argument containing                video file, line below */             myprocess.startinfo.arguments = filename;             myprocess.startinfo.createnowindow = true;             myprocess.enableraisingevents = true;             myprocess.exited += new eventhandler(myprocess_exited);             myprocess.start();         }         catch (exception ex)         {             /* handle exceptions here */         }     }      public bool finished()     {         return finishedflag;     }      /* handle exited event (process closed) */     private void myprocess_exited(object sender, system.eventargs e)     {         finishedflag = true;     }      public static void main(string[] args)     {         converterclass converter = new converterclass();         converter.convertvideo("my_video.avi");          /* should watch when finished method            returns true, , act accordingly */         /* in console, host application (we)            may finish before guest application (convert.exe),            need wait here */         while(!converter.finished()) {             /* wait */             thread.sleep(100);         }          /* video finished converting */         doactionsafterconversion();     } } 

when program exits, finishedflag set true, , finished() method start returning that. see main "how should it".


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -