int i=0;
 private void timer1_Tick(object sender, EventArgs e)
        {
              i++;
              if(i<=10)
                  存入数组;
              else
                 timer5.Stop();
                  写入文件,清空数组;
        }
private void timer2_Tick(object sender,EnventArgs e)
       {
              timer1.Start();
        }
                   
  其中,Timer1的Interval是1000,Timer2的Interva是10000,为什么不能在Timer2中实现Timer1的调用呢      

解决方案 »

  1.   

    没看出你time5是什么意思
      

  2.   


    而且没看出timer2有啥用。难道是因为timer5其实是time1. timer2的作用是为了启动已经stop的timer1? 
      

  3.   

    表达不清楚,看你的代码下面的方法就能实现int i = 0;
                while (true)
                { 
                    i++;
                     if(i<=10)
                     { //存入数组;
                     }
                     else
                     {//写入文件,清空数组;
                     i = 0;
                     System.Threading.Thread.Sleep(10000);
                     }
                     System.Threading.Thread.Sleep(1000);
                }
      

  4.   


    //改一下
               int i = 0;
                while (true)
                { 
                    i++;
                     if(i<=10)
                     { //存入数组;
                     System.Threading.Thread.Sleep(1000);
                     }
                     else
                     {//写入文件,清空数组;
                     i = 0;
                     System.Threading.Thread.Sleep(10000);
                     }
                     
                }
      

  5.   

    int i=0;
     private void timer1_Tick(object sender, EventArgs e)
      {
      i++;
      if(i<=10)
      存入数组;
      else
      timer1.Stop();
      写入文件,清空数组;
      }
    private void timer2_Tick(object sender,EnventArgs e)
      {
      timer1.Start();
      }
        
      其中,Timer1的Interval是1000,Timer2的Interva是10000,为什么不能在Timer2中实现Timer1的调用呢  
     
     
      

  6.   

    我的想法是在timer1中每秒都刷新,获得实时值,存入数组,每隔十秒存入一次文件,timer2就是每十秒调用一次timer1
      

  7.   

               //用while
                int i = 0;
                while (true)
                {
                    i++;
                    //存入数组;
                    if (i >= 10)
                    {
                        //写入文件,清空数组;
                        i = 0;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
                //用timer
                int i=0;
                private void timer1_Tick(object sender, EventArgs e)
               {
                    i++;
                    //存入数组;
                    if (i >= 10)
                    {
                        //写入文件,清空数组;
                        i = 0;
                    }
               }