C # Timer Implementation of automatic implementation method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.