使用Timer控件.设置:ENABLE=TRUE设置:INTERVAL=1000(毫秒)然后对TIMER对象的ONTIMER编程。

解决方案 »

  1.   

    Timer控件
    timer的interval设为1000
      

  2.   

    我的意思是有没有像java那样可以取得毫秒级的时间间隔,用控件对效率肯定有影响吧
      

  3.   

    看一下一楼的,把INTERVAL=1,不就行了。
      

  4.   

    参考一个例子public class Class1 {
        static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
        static int alarmCounter = 1;
        static bool exitFlag = false;
     
        // This is the method to run when the timer is raised.
        private static void TimerEventProcessor(Object myObject,
                                                EventArgs myEventArgs) {
           myTimer.Stop();
     
           // Displays a message box asking whether to continue running the timer.
           if(MessageBox.Show("Continue running?", "Count is: " + alarmCounter, 
              MessageBoxButtons.YesNo) == DialogResult.Yes) {
              // Restarts the timer and increments the counter.
              alarmCounter +=1;
              myTimer.Enabled = true;
           }
           else {
              // Stops the timer.
              exitFlag = true;
           }
        }
     
        public static int Main() {
           /* Adds the event and the event handler for the method that will 
              process the timer event to the timer. */
           myTimer.Tick += new EventHandler(TimerEventProcessor);
     
           // Sets the timer interval to 5 seconds.
           myTimer.Interval = 5000;
           myTimer.Start();
     
           // Runs the timer, and raises the event.
           while(exitFlag == false) {
              // Processes all the events in the queue.
              Application.DoEvents();
           }
        return 0;
        }
     }
      

  5.   

    用DateTime.Now.Ticks来获得timer控件的运行的时间刻度值,这样就可以精确很多了!我估计可能达到微秒级或者更短!