The example in this paper describes the method of automating C # timer implementation. Share to everyone for your reference. The implementation method is as follows:
The code is as follows:
Here's a time to open the form to perform the button on the timer.
private void Form1_Load (object sender, EventArgs e)
{
System.Timers.Timer Ptimer = new System.Timers.Timer (5000);//Every 5 seconds, no winfrom comes with
ptimer.elapsed+=ptimer_elapsed;//delegate, the method to execute
Ptimer.autoreset = true;//Gets the timer to execute automatically
ptimer.enabled = true;//This must be written, otherwise the timer will not be executed
Control.checkforillegalcrossthreadcalls = false;//This does not quite understand, pending research
}
private void Ptimer_elapsed (object sender, System.Timers.ElapsedEventArgs e)
{
Button1_Click (null, NULL);
}
private void Button1_Click (object sender, EventArgs e) {}
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
C # Timer Implementation of automatic implementation method
This address: http://www.paobuke.com/develop/c-develop/pbk23188.html
Related content use C # regular expressions to validate Chinese characters (instance code) in C # implement FTP picture upload feature (M.F.B. s) the listbox in WPF implements a block-based display of elements to drill down on the structure defined by a struct in C # programming
Common misconceptions of the Equals method in C # 23 Design Patterns C # Implements the method of adapting the ListBox to the maximum item width the lock system in C # multithreaded programming (ii)
C # Timer Implementation of automatic implementation method