C # timed execution function (winForm)

Source: Internet
Author: User

Need to use Timer Timer control

Timer1. Interval Set time interval

Timer1. Trigger event when Tick arrives at time interval

Test_tick Time processing function

Timer1. Tick + = new System.EventHandler (Test_tick);
Delegate to handle events, you can generally add the above code to register the Test_tick handler function in the constructor of the form InitializeComponent the constructor interface component function;

Of course, you don't have to worry about it. Double-click the Timer control directly in the Form view, and the system will automatically help you generate a handler function similar to Test_tick

Typically, you need to use timer1. Start ()//Startup timer timer1. Stop ();. Turn off the Timer method

The general code process is as follows:

private void Form_Load (object sender, EventArgs e)

{timer1. Interval = 1000;

Timer1. Start ();}


private void Test_tick (...)

{

The function body that needs to be executed every second, and the function is executed every second after timer start

}

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.