小编K.R*_*pur的帖子

C#如何制作返回DialogResult的异步MessageBox?

我的MessageBox是异步的,但是如何返回DialogResult?

这是我的代码:

class AsyncMessageBox
{
    private delegate void ShowMessageBoxDelegate(string strMessage, string strCaption, MessageBoxButtons enmButton, MessageBoxIcon enmImage);
    // Method invoked on a separate thread that shows the message box.
    private static void ShowMessageBox(string strMessage, string strCaption, MessageBoxButtons enmButton, MessageBoxIcon enmImage)
    {
        MessageBox.Show(strMessage, strCaption, enmButton, enmImage);
    }
    // Shows a message box from a separate worker thread.
    public void ShowMessageBoxAsync(string strMessage, string strCaption, MessageBoxButtons enmButton, MessageBoxIcon enmImage)
    {
        ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);
        caller.BeginInvoke(strMessage, strCaption, enmButton, enmImage, null, null);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asynchronous messagebox dialogresult winforms

0
推荐指数
1
解决办法
7617
查看次数

标签 统计

asynchronous ×1

c# ×1

dialogresult ×1

messagebox ×1

winforms ×1