[Gtk-sharp-list] waiting for an asynchronous operation to finish

Jeroen Zwartepoorte jeroen.zwartepoorte at gmail.com
Fri Sep 30 03:52:49 EDT 2005


Good arguments. But for discussion's sake: how would i properly block
until the callback was called?

Jeroen

On 9/30/05, Ben Maurer <bmaurer at ximian.com> wrote:
> On Fri, 2005-09-30 at 09:07 +0200, Jeroen Zwartepoorte wrote:
> > On 9/29/05, Ben Maurer <bmaurer at ximian.com> wrote:
> > > > System.Threading.Thread has Suspend() and Resume() methods, but how do
> > > > these interact with the GLib mainloop?
> > >
> > > That would stop the thread completely. You don't want that. Basically
> > > Suspend/Resume == bad.
> > >
> > > What you want to do is this:
> > >
> > > Drive.Mount (delegate (bool succeeded) {
> > >        Application.Invoke (delegate {
> > >                if (!succeeded)
> > >                        DisplayErrorDialog();
> > >                else
> > >                        DoStuff ();
> > >        });
> > > });
> >
> > The problem with that is that the location where i call Drive.Mount is
> > inside a TreeView TestExpandRowHandler. I need to know if the
> > Drive.Mount call succeeded or not before i can return from that
> > handler (args.RetVal determines whether or not the row can be
> > expanded).
> >
> > If i read your code right, it just defines a new delegate which gets
> > called at a later stage? (the code above doesn't wait for Drive.Mount
> > to report back)
>
> well, blocking on the file system is probably not-the-best-idea (TM). if
> it is NFS and I just went off-line, it will freeze.
>
> Try what nautilus does, add a fake entry "Loading..." and if it turns
> out that there are no children, just remove it.
>
> -- Ben
>
>


More information about the Gtk-sharp-list mailing list