一秒钟后执行

ContractedBlock.gif ExpandedBlockStart.gif Code
       
      System.Windows.Forms.Timer timer 
= new System.Windows.Forms.Timer();   
      
private void Timer_Tick(object sender, EventArgs e)
        {
            timer.Enabled 
= false;

            MessageBox.Show(
"1秒钟后我被执行了!");
           
            
        }
      
        
private void button1_Click(object sender, EventArgs e)
        {
            
            timer.Interval 
= 1000;
            timer.Tick 
+= new EventHandler(Timer_Tick);
            timer.Start();
        }

转载于:https://www.cnblogs.com/master-zhu/archive/2009/08/20/1550314.html

你可能感兴趣的:(一秒钟后执行)