日期:2014-05-17  浏览次数:20852 次

C#求解timer控件知识
大家好,,经过一晚上的奋斗,和,start()和stop()的方法好奇怪,我stop后,再也启动不了,最后参照msdn上timer的用法,我也终于解决了下我自己贴子的问题,
http://bbs.csdn.net/topics/390368476
我的解决方法是::
       
 public void hexing_name_select()
        {
            hexing_line hexing = new hexing_line();
            for (int i = 0; i < hexing.hexing_name.Count(); i++)
            {
                hexing_date.Rows.Add();
                hexing_date.Rows[i].Cells[0].Value = hexing.hexing_name[i];
                hexing_date.Rows[i].Cells[1].Value = hexing.hexing_ip[i];
            }
        }

        public void hexing_ping(object obj)
        {
            int i = Convert.ToInt32(obj);
            Ping pp = new Ping();
            PingReply ppResult = pp.Send(Convert.ToString(hexing_date.Rows[i].Cells[1].Value), 10);
            hexing_date.Rows[i].Cells[2].Value = ppResult.RoundtripTime.ToString();
            hexing_date.Rows[i].Cells[3].Value = ppResult.Status.ToString();
            hexing_date.Rows[i].Cells[4].Value = z;
        }
 static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
        public void hexing_click_select(object source, EventArgs e)
        {
          //myTimer.Stop();我尝试了下,这个stop不stop都不会影响到ping的时候会卡界面的情况。
            z+=1;
            if (z < 10)
            {
               hexing_thread();
               myTimer.Enabled = true;////是不是这一句起到了作用?求解
            }
            else
            {
                myTimer.Enabled = false;
            }
        }
        public void he