Application. Idle Event
Description: Occurs when the application finishes processing and is about to enter an idle state. If you have a task that must be performed before the thread becomes idle, attach them to this event.
1 Public Partial classForm1:form2 {3 /// <summary>4 ///number of executions during idle period5 /// </summary>6 Private intExecutetimes =0;7 8 PublicForm1 ()9 {Ten InitializeComponent (); One } A - Private voidBtngettime_click (Objectsender, EventArgs e) - { theApplication.idle + =Application_idle; - } - - /// <summary> + ///occurs when the program finishes processing and enters an idle state - /// </summary> + /// <param name= "Sender" ></param> A /// <param name= "E" ></param> at Private voidApplication_idle (Objectsender, EventArgs e) - { -Txttime.text =DateTime.Now.ToString (); - -executetimes++; - if(executetimes==9) in { -Application.idle-=Application_idle; toMessageBox.Show ("has performed 10 times in CPU idle time"); + } - } the}
Application.idle Event usage in WinForm