« Return to Thread: Check Process state in an GUI app

Re: Check Process state in an GUI app

by hellboy195 :: Rate this Message:

Reply to Author | View in Thread


Chris Howie-3 wrote:
On Jan 21, 2008 2:34 PM, hellboy195 <hellboy195@gmail.com> wrote:
> Sure, no problem. Though I don't know if I should post the whole one ore not
> ^^. anyway. here it is :
>
> [snip]
>
> In my eyes it's very ugly code and beside my problem here I would appreciate
> any suggestions ;)
> Thx :D

Thanks, that helped a lot.

Basically, you are going to have to change your entire code flow and
break it apart a bit.  You are going to need one method that is
responsible for checking your preconditions (popping a dialog to
confirm, etc) and starting the process on one file.  Then in the
Exited handler you need to start the process on the next file.  So
something like this pseudo-code:

OnConvertClicked():
    ProcessNextFile();

ProcessNextFile():
    CheckPreconditions;
    StartProcess;
    AttachEventHandler -> Application.Invoke -> OnProcessCompleted;

OnProcessCompleted():
    RemoveProcessedFileFromList;
    If MoreFilesToProcess
        ProcessNextFile();

Something like that.  You may want to make your window insensitive
during the processing too, or at least any buttons that can change the
state of your application.  You don't want people modifying the file
list while you are processing, for example.

--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
You are helping me a lot. Thank you very much. Yeah as you can see I already tried to set all buttons,.. insensetive. Thx for you posted solution but I'm totally new to this. Can you give me a more specific code? Unfortunately the docs are really really *unfilled* I wouldn't ask

 « Return to Thread: Check Process state in an GUI app