In addition to standard eventargs members, the elapsedeventargs class exposes a common signaltime attribute, which contains a precise time when the timer time slice disappears.
Private Static void timeevent (Object source, elapsedeventargs E)
{
// Get hour minute second. If it is equal to a value, execute Program .
Int inthour = E. signaltime. hour;
Int intminute = E. signaltime. minute;
Int intsecond = E. signaltime. Second;
// Customize the time. For example, execute a function.
Int ihour = 10;
Int iminute = 30;
Int isecond = 00;
// Set the execution to start once every second
If (intsecond = isecond)
{
Console. writeline ("the execution starts once every second! ");
}
// Set the execution to start 30 minutes each hour
If (intminute = iminute & intsecond = isecond)
{
Console. writeline ("the execution starts once every 30 minutes! ");
}
// Set the program to start running at 10:30:00 every day
If (inthour = ihour & intminute = iminute & intsecond = isecond)
{
Console. writeline ("Run at every day! ");
}
}
}
}