这么多消息框正在显示 [英] so many message boxes are displaying

查看:78
本文介绍了这么多消息框正在显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计....我正在练习C#编码...就像在练习..我刚刚创建了一个应用程序...它显示HH:MM:SS AM / PM ..它工作得很好,所有我想做的是..

在特定时间它应该显示一个消息框显示消息...

例如,如果时间是01:00:00 PM ..它应该显示一个消息框,上面有一条消息=午餐时间

所以我写了一个代码......它显示了一条消息,唯一的问题是sooooo很多消息即将发布...近50条消息正在推迟....你们可以帮助我吗?

我写的代码是





hi guys.... i am practicing C# coding... as in practicing.. i just created an application for time... it displays HH:MM:SS AM/PM.. it is working nice and all i want to do is..
at particular time it should display a messagebox showing a message...
for example if time is 01:00:00 PM.. it should display a messagebox with a message = "time to lunch"
so i written a code... it showing a message and the only problem is sooooo many messages are coming... nearly 50 messages are dislaying at time.... can you guys help me in this,,
the code i written is


private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = DateTime.Now.ToString("HH:mm:ss");
           if(label1.Text==DateTime.Now.ToString("11:55:00"))
            {
                MessageBox.Show("time to Lunch");
            }







请修改代码来控制消息框..




please modify the code to control the messagebox..

推荐答案





将间隔更改为1分钟。即60000毫秒秒。





如下所示更改您的勾选事件:



Hi,

Change the Interval to 1 minute. i.e. 60000 Millie seconds.


Changer your tick event as below:

private void timer1_Tick(object sender, EventArgs e)
      {
          label1.Text = DateTime.Now.ToString("HH:mm");
          if (label1.Text == DateTime.Now.ToString("12:16"))
          {
              MessageBox.Show("time to Lunch");
          }
      }


试试这个

转到timer属性并将其interval属性更改为1000意味着1秒,所以你的代码会在1秒后触发。







如果它为你工作,请接受它

或者还原以获得进一步的清除。
Try this
Go to timer Property and change its interval property to 1000 that mean 1 sec so your code fires after 1 second.



Accept it if its work for you
or revert back for further clearnces.


我已经测试了你的代码它是否正常工作但是因为间隔时间较少而消息箱很多

修复你的计时器间隔如下所示

I have tested your code it's working properly but lots of messagebox coming due to less interval
fix your timer interval like below
private void Form1_Load(object sender, EventArgs e)
       {
          //Set to 1 second.
           timer1.Interval = 1000;
       }


这篇关于这么多消息框正在显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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