[MonoDevelop] One-shot dialogs from add-ins

Lluis Sanchez Gual lluis at novell.com
Wed Mar 18 20:11:11 EDT 2009


El dc 18 de 03 de 2009 a les 13:05 -0700, en/na Casey Marshall va
escriure:
> On Mar 18, 2009, at 11:51 AM, Chris Howie wrote:
> 
> > On Wed, Mar 18, 2009 at 2:43 PM, Casey Marshall
> > <casey.s.marshall at gmail.com> wrote:
> >> Because, I want to do this:
> >>
> >>   Application.Invoke(delegate {
> >>     run-dialog-and-get-result();
> >>     signal-caller(); // only signal if not originally in GUI thread?
> >>   });
> >>   wait-to-be-signaled(); // only wait if not in GUI thread?
> >>   use-result();
> >
> > If you use e.g. a ManualResetEvent then this will work exactly as you
> > describe.  When you signal the caller (via Set()) this will get
> > stored.  If you are running on the same thread, WaitOne will return
> > immediately since you set it earlier.  If you are on separate threads
> > then the WaitOne will return when Set is called.
> >
> 
> OK, this seems to do it:
> 
>    string password = null;
>    ManualResetEvent mre = new ManualResetEvent(false);
>    Gtk.Application.Invoke(delegate {
>      password = RunPasswordDialog();
>      mre.Set();
>    });
>    Gtk.Main.Iteration(); // must do this to run the delegate above!
>    mre.WaitOne();

A more simple solution:

string password = null;
DispatchService.GuiSyncDispatch (delegate {
  password = RunPasswordDialog ();
});


> 
> Which was kind of non-obvious, but it works now, and no longer messes  
> up the TreeView.
> 
> Thanks!
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list



More information about the Monodevelop-list mailing list