https://bugzilla.novell.com/show_bug.cgi?id=430477

User [EMAIL PROTECTED] added comment
https://bugzilla.novell.com/show_bug.cgi?id=430477#c4


Robert Jordan <[EMAIL PROTECTED]> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
                 CC|                                                |[EMAIL 
PROTECTED]




--- Comment #4 from Robert Jordan <[EMAIL PROTECTED]>  2008-09-29 03:57:34 MDT 
---
Jon, you probably did not compile with -d:DEBUG

Steve, using MessageBox alone is a bad idea because Debug.Assert might be
called
from another thread. You'd need to invoke MessageBox from the main thread,
maybe
using a synchronization context:


SyncronizationContext ctx;
DialogResult result;

public GuiListener ()
{
    // assumes GuiListener..ctor is called from the main thread.
    SyncronizationContext ctx = SynchronizationContext.Current
        as WindowsFormsSynchronizationContext;
    if (ctx == null) throw new InvalidOperationException ();
}


DialogResult ShowDebugAssertMsg(string message, string detailMessage)
{
    result = DialogResult.Ignore;

    ctx.Send (delegate(object state) {
        result = MessageBox.Show (...)
    }, null);

    return result;
}


For .NET 1.1 we'd probably need to resort to Control.Invoke:

DialogResult ShowDebugAssertMsg(string message, string detailMessage)
{
    result = DialogResult.Ignore;

    // FIXME: is there another way to get a Control instance from the main
thread?
    Control ctl = Form.ActiveForm;
    if (ctl != null) {
        ctl.Invoke (delegate {
            result = MessageBox.Show (...)
        });
    }

    return result;
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to