[Gtk-sharp-list] Check Process state in an GUI app

Michael Hutchinson m.j.hutchinson at gmail.com
Mon Jan 21 12:52:53 EST 2008


On Jan 21, 2008 11:58 AM, hellboy195 <hellboy195 at gmail.com> wrote:
>
> hi,
> I'm currently trying to write a very very simple front-end for ffmpeg with
> gtk#.
> My Code looks like this:
>
> First I check if a file already exits with File.Exits(path)
> MessageDialog -> Overwrite YesNO.
>
> Then the I start ffmpeg with Process.Start().
> Then I want show a MessageDialog if the process finished so I did it like :
>
> while(!proc.HasExited) {}
> MessageDialog -> "Encoding finished";
>
> This is working good but this causes some bugs. E.g: If I do Overwrite it
> "yes". The MessageDialog isn't destroyed until the process finished. If I
> delete this while {} it's working correct but the Message appears
> immediately and not after the process hast Finished. Using if is also not
> that good I suppose :/
>
> Any solution? Thx in advance :)

Your loop is hanging the GUI thread, by not allowing GTK to return to
its main loop (in which it does all the drawing etc).

Handle the Process.Exited thread instead:

proc.Exited += delegate {
    MessageDialog -> "Encoding finished";
};

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Gtk-sharp-list mailing list