Timer controls timer and. NET Timer timer in. net
This chapter introduces how to use Timer controls. Describes common attributes and events of the Timer control.
1. IntervalThe time interval of the Timer control.
If the type is int, the default value is millisecond.
2. EnabledIndicates whether the Timer control is activated.
If activated, the Tick event is executed as soon as it enters the Timer. So the default value is false.
3. Start ()Method
Start execution
4. Stop ()Method
Stop execution
5. TickEvent
Indicates the code to be executed by the Timer control.
General Usage
1.Add a Timer control
2.After setting the necessary attributes. Write the timer_Tick event directly. Write a stop condition in the event.
Call Timer using Lambda expressions
Timer timer = new Timer ();
Timer. Interval = 100;
// Use a Lambda expression
Timer. Tick + = (sender, e) =>
{
If (balabara)
{
Timer. Stop ();}
};
Timer. Start ();