如何在C#Windows应用程序中每1分钟显示一个消息框 [英] How to display a message box in every 1 minute in c# windows application

查看:50
本文介绍了如何在C#Windows应用程序中每1分钟显示一个消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#Windows应用程序中每1分钟显示一个消息框

How to display a message box in every 1 minute in c# windows application

推荐答案



您也可以尝试使用 Threading .使用"Thread.Sleep" 方法使线程等待1分钟.

问候,
Suresh
Hi,

You can also try using Threading. Make the thread to wait for 1 minute using "Thread.Sleep" method.

Regards,
Suresh


private void button1_Click(object sender, EventArgs e)
      {
          while (true)
          {
              System.Threading.Thread.Sleep(60 * 1000);
              MessageBox.Show("Hello!");
          }
      }







OR

private void button1_Click(object sender, EventArgs e)
     {
         while (true)
         {
             System.Threading.Thread showSeperate = new System.Threading.Thread(new System.Threading.ThreadStart(Show_Message));
             System.Threading.Thread.Sleep(60 * 1000);
             showSeperate.Start();
         }
     }
     void Show_Message()
     {
         MessageBox.Show("Hello!");
     }


使用计时器控件,并在其Tick事件中显示消息框.
搜索google以获取计时器控件的功能.非常简单.
Use Timer control, and display Message Box in its Tick event.
Search google to get the functionality of a Timer Control. Its very simple.


这篇关于如何在C#Windows应用程序中每1分钟显示一个消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆