zoukankan      html  css  js  c++  java
  • Timer控制开始、停止例子【转】

    public partial class Form1 : Form
        {
           static public bool flag; 
            public Form1()
            {
                InitializeComponent();
            }

            static public void Monitor()
            { 
                    string mystring = "hello!";
                    for (int i = 0; i < mystring.Length; i++)
                    {
                        if (flag == false)  //马上结束
                            break;
                        else
                            MessageBox.Show(mystring[i].ToString());
                    }
            }
            private void 开始_Click(object sender, EventArgs e)
            {
                timer1_Tick(null,null); //立即开始
                timer1.Enabled = true;
                flag = true;
            }

            private void 结束_Click(object sender, EventArgs e)
            {
                timer1.Enabled = false;
                flag = false;
            }

            private void timer1_Tick(object sender, EventArgs e)
            {
                Thread threadMonitor = (new Thread(new ThreadStart(Monitor)));
                threadMonitor.Start();
            }
        }

  • 相关阅读:
    MT【305】丹德林双球
    MT【304】反射路径长度比
    MT【303】估计
    MT【302】利用值域宽度求范围
    MT【301】值域宽度
    MT【300】余弦的三倍角公式
    MT【299】对数型数列不等式
    MT【298】双参数非齐次
    xadmin 自定义actions
    xadmin 添加自定义权限
  • 原文地址:https://www.cnblogs.com/gates/p/3549012.html
Copyright © 2011-2022 走看看