[MonoDevelop] One-shot dialogs from add-ins
Casey Marshall
casey.s.marshall at gmail.com
Wed Mar 18 16:05:38 EDT 2009
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();
Which was kind of non-obvious, but it works now, and no longer messes
up the TreeView.
Thanks!
More information about the Monodevelop-list
mailing list