我有在我使用的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