[Gtk-sharp-list] Check Process state in an GUI app
    Chris Howie 
    cdhowie at gmail.com
       
    Mon Jan 21 14:41:34 EST 2008
    
    
  
On Jan 21, 2008 2:34 PM, hellboy195 <hellboy195 at 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
    
    
More information about the Gtk-sharp-list
mailing list