我有在我使用的Web引用顯示帳戶特定user.Here當前短信平衡一個Windows應用程序是我使用的代碼:如何在C#中進行處理時顯示「請稍候」消息框?
Thread t1 = new Thread(new ThreadStart(ShowWaitMessage));
t1.Start();
XmlNode xmlnde = ws.BSAcBalance(txtLoginId.Text, txtPassword.Text);
string sResponse = xmlnde.ChildNodes[0].InnerXml;
if (sResponse.Contains("Authentication Failed"))
{
t1.Abort();
MessageBox.Show("Invalid login id or password !", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
{
t1.Abort();
MessageBox.Show("Total balance in your account is Rs : " + sResponse , "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
public void ShowWaitMessage()
{
MessageBox.Show("Please Wait ......");
}
的ws.BSAcBalance是將應用程序連接到Web的方法,需要大約2到3秒才能執行。與此同時,我想顯示一個「Please Wait」消息,我正在嘗試使用線程並通過消息框顯示消息。現在,一旦所需操作完成,我想要「請稍候」消息框隱藏,但那不會發生,我該怎麼辦?
請等待不應該是一個消息框,在所有。它應該像啓動畫面或非模態窗口。它是一個簡單的窗體,你可以使用'form.Close()'關閉它'永遠不要使用'Thread.Abort'。 – 2014-12-06 12:40:42
讓你的用戶界面脫離線程。顯示消息,在另一個線程中進行調用,並在返回時使用該值調用UI。在回調函數中顯示值並隱藏框。 – dbugger 2014-12-06 12:44:56
將鼠標光標更改爲等待光標可能就足夠了嗎? – RenniePet 2014-12-06 13:24:52