Asp.net executes tasks at a specified point every day.

Source: Internet
Author: User

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 !;
}
}

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.