【C#】执行费时操作时提醒框的添加(开线程)

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-29 15:42   11   0

在执行费时操作时,需要添加操作提醒框,提醒用户正在执行操作,并没有程序崩溃。

添加一个窗体,名为:checkMessage

在点击费时操作的按钮时,添加程序:

Thread thdSub = new Thread(new ThreadStart(showkmess));
                        thdSub.Start();//开启提醒的对话框

在按钮最后关闭比线程:

thdSub.Abort();//关闭线程
最好在管线程后加上MessageBox,告诉用户操作已经执行完毕。
在开头引用:

using System.Threading;
using System.Diagnostics;

然后,函数showmess定义如下:

 public void showmess()
        {
            checkMessage cc = new checkMessage();
            cc.StartPosition = FormStartPosition.CenterParent;
            cc.ShowDialog();
            cc.Close();
        }
OK,提醒框做好了!

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP