如何在Windows应用程序中的文件发送过程中设置消息 [英] how to set message when file sending process in windows application
本文介绍了如何在Windows应用程序中的文件发送过程中设置消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Windows应用程序中向服务器发送文件时发出消息请稍候。所以建议我怎么做
i want to put message "please wait" when sending file to server in windows application .so suggest me to how to do
推荐答案
有'丑陋'':在控件(例如文本框)上写下你的消息,然后同步启动文件发送操作,结果是冻结UI的结果。
有'正确的方法':开始你的文件发送操作在工作线程上,这样GUI就会保持响应。
There is 'the ugly way': write your message on a control (e.g. a textbox) and then start synchronously the file sending operation, with the net effect of freezing the UI.
There is 'the proper way': start your file sending operation on a worker thread, this way the GUI would remain responsive.
HI
你可以尝试这样。
创建并设计一个窗体
,类似于messagebox
外观。
为它添加一个标签,上面写着请等待...
并执行以下操作
HI you can try like this.
Create and design awindows form
similar tomessagebox
look and feel.
add a label to it saying "Please wait...
"
and do the following
private void btnSendFile_Click(object sender, EventArgs e)
{
Form2 frmMessageBox = new Form2();
frmMessageBox.Show();
// your code for sending file....
// after your file is sent then you can close the message form
frmMessageBox.Close();
}
您可以使用Backgroundworker:
[ ^ ]
You can use the Backgroundworker:
[^]
这篇关于如何在Windows应用程序中的文件发送过程中设置消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文