溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

測試Application.Idle

發布時間:2020-06-26 21:58:18 來源:網絡 閱讀:576 作者:fitel 欄目:編程語言

    最近在DoNet項目中需要用到Application.Idle功能函數,平時基本沒用過。今天寫點代碼測試一下,一目了然。
    Application.Idle的英文描述為:“Occurs when the application finished processing and is about to enter idle state.”,字面意思 當應用程序處于空閑狀態時執行相應代碼。
    還是上代碼,源代碼也可直接下載。

 

測試Application.Idle

  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.ComponentModel; 
  4. using System.Data; 
  5. using System.Drawing; 
  6. using System.Linq; 
  7. using System.Text; 
  8. using System.Windows.Forms; 
  9.  
  10. namespace 測試Application.Idel 
  11.     public partial class Form1 : Form 
  12.     { 
  13.         private int excuteTimes = 0;//空閑期間執行的次數 
  14.  
  15.         public Form1() 
  16.         { 
  17.             InitializeComponent(); 
  18.         } 
  19.  
  20.         /// <summary> 
  21.         /// 時間處理,獲取最新的系統時間在文本框中顯示 
  22.         /// </summary> 
  23.         private void ProcessTime(object sender, EventArgs e) 
  24.         { 
  25.             textBox1.Text = System.DateTime.Now.ToString(); 
  26.             excuteTimes++; 
  27.             if (excuteTimes == 9) 
  28.             { 
  29.                 Application.Idle -new EventHandler(ProcessTime); 
  30.                 MessageBox.Show("已經在CPU空閑期間執行了10次!"); 
  31.             } 
  32.         } 
  33.  
  34.         /// <summary> 
  35.         /// 按扭,獲取時間 
  36.         /// </summary> 
  37.         private void btnGetTime_Click(object sender, EventArgs e) 
  38.         { 
  39.             Application.Idle += new EventHandler(ProcessTime); 
  40.         } 
  41.     } 


 

 

附件:http://down.51cto.com/data/2361603
向AI問一下細節
推薦閱讀:
  1. MySQL測試
  2. PHP測試

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女