CopyCode The Code is as follows: public static void clearcountbytime ()
{
System. Timers. Timer atimer = new system. Timers. Timer ();
Atimer. elapsed + = new elapsedeventhandler (timeevent );
// Set the interval of the triggering time to 1 second.
Atimers. interval = 1000;
Atimer. Enabled = true;
}
Private Static void timeevent (Object source, elapsedeventargs E)
{
// Obtain the hour minute second. Execute the command if it is equal to a value.
Int inthour = E. signaltime. hour;
Int intminute = E. signaltime. minute;
Int intsecond = E. signaltime. Second;
// Custom time, executed at 00:00:00
Int ihour = 00;
Int iminute = 00;
Int isecond = 00;
// Set the execution to start at 00:00:00 every dayProgram
If (inthour = ihour & intminute = iminute & intsecond = isecond)
{
Clearcount ();
}
}
Public static void clearcount ()
{
String SQL = "stored procedure to be executed ";
Int result = sqlhelper. executenonquery (commandtype. storedprocedure, SQL );
If (result> 0)
{
// Todaycount is cleared successfully !;
}
Else
{
// Todaycount resetting failed !;
}
}