C # multithreading (4) -- Use of Timer

Source: Internet
Author: User

1. the role of the Timer class is to set a timer to regularly execute the user-specified function, and the transfer of this function depends on another Proxy object timercallback, which must be specified when the timer object is created, and cannot be changed. After the timer starts, the system automatically creates a new thread and executes the user-specified function in this thread.

2. timer timer = new timer (timerdelegate, S, 1000,100 0); the first parameter specifies the timercallback proxy object; the second parameter indicates the same as the waitcallback proxy object mentioned above, as a data transmission object, it is passed to the method to be called. The third parameter is the delay time-the time from the start of the timer, in milliseconds; the fourth parameter is the timer interval. After the timer starts, the method represented by timercallback will be called every so long time, in milliseconds. This statement sets the timer delay time and interval to one second.

3. the timer settings can be changed as long as timer is called. the change () method is a parameter type overload method. The general prototype is as follows: public bool change (Long, long );

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.