一直认为Telerik Silverlight RadWindow控件的ShowDialog()方法会显示一个模式对话框(modal dialog) - 就像System.Windows.MessageBox.Show方法一样。但是,那不是一个真正的模式对话框:ShowDialog()方法不是同步等待窗口关闭后再返回,而是异步的,即执行后马上返回,继续执行后续代码。
来自Telerik 论坛的回复:
This is a limitation of Silverlight, since there is no way you can stop the execution thread and get synchronous results. This is one of the reason our RadWindow doesn't work synchronously
(http://www.telerik.com/community/forums/silverlight/window/problem-with-threads-how-radwindow-show-works.aspx)
真正的模式对话框还是那个System.Windows.MessageBox.Show 可是界面不敢恭维。该方法调用了Silverlight的Core代码:
[DllImport("agcore", EntryPoint="MessageBox_ShowCore", CharSet=CharSet.Unicode)]
private static extern uint MessageBox_ShowCoreNative(IntPtr context, [MarshalAs(UnmanagedType.LPWStr)] string messageBoxText, [MarshalAs(UnmanagedType.LPWStr)] string caption, uint type, out int result);
然后Core又调用了OS的平台方法?因为msdn中有如下描述:
The message box may have a slightly different appearance on different platforms. For example, the message box includes an icon when it is displayed on a Macintosh.
http://msdn.microsoft.com/en-us/library/system.windows.messagebox(VS.95).aspx
似乎这个还有一个问题:有人发现这个会阻断WCF的调用BackgroundWorker上的线程