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();
            }
        }

  • 相关阅读:
    [JSOI2009] 游戏
    CF1148H Holy Diver
    [提高组集训2021] 模拟赛3
    CF1458F Range Diameter Sum
    [游记] CSP2021
    CF1396E Distance Matching
    CF1396D Rainbow Rectangles
    【LeetCode】1. 两数之和
    【随笔】开通博客园过程
    MyISAM与InnoDB的区别是什么?
  • 原文地址:https://www.cnblogs.com/gates/p/3549012.html
Copyright © 2011-2022 走看看