[Gtk-sharp-list] How to show custom window and do the computation in the background

Maciej Pilichowski bluedzins at wp.pl
Sun Jun 27 09:11:47 EDT 2010


Hello,

  David, Christopher -- thank you very much for your help.

On Friday 25 June 2010 22:20:10 Christopher David Howie wrote:

> Here is the modified logic you should use.  Changed lines are
> annotated with +.
>
> --> show main window
> --> create file dialog
> --> set filename for file dialog
> +-> the above triggers the following method:
>   --> create progress dialog
>   +-> spawn thread, thread will:
>     +-> load file, using Application.Invoke to change the progress
> bar on the created dialog
>     +-> once done, Destroy() the dialog
>   +-> show progress dialog, using dialog.Show()

I moved the last step -- showing progress dialog -- to the thread as 
first step. This way I have a guarantee that altering dialog make 
sense (because it is visible).

Everything works fine (canceling dialog too), so it was quite 
surprising for me, it was so easy ;-) Well, after you know what to 
do :-).

> Note the pattern: set up the GUI for the operation, do the work on
> another thread, and update the GUI from that thread.  The mail
> thread should be in the GLib main loop code as much as possible,
> since whenever it is not processing the event queue the UI will be
> frozen.

Thank you.

Just thinking -- would you like/mind to add this to the web page you 
sent link to? As use case. If you don't have time I could write a 
piece.

Cheers,


More information about the Gtk-sharp-list mailing list