WebService Timer timer in C # automatically stops running after a period of time

Source: Internet
Author: User

I use. NET to do a timer timer, timed to get text messages and give replies, but probably after more than 10 hours, timer timer will automatically stop, and then send text messages can not receive a reply, need to re-run the timer in the server can, ask you!
I am in the. NET Framework, there is a Global.asax global application file, post code:
public class Global:System.Web.HttpApplication
{
Double Itimerinterval;
System.Timers.Timer Timer = new System.Timers.Timer ();
Smsrun Smsrun = new Smsrun ();
Object Objlock = new Object ();
protected void Application_Start (object sender, EventArgs e)
{
Code to run when the application starts
Code to run when a new session is started
Setaccount ();
Timer. Start ();//Timer starts
}

protected void Application_End (object sender, EventArgs e)
{
Timer. Stop ();
}

private void Setaccount ()
{
Double. TryParse (configurationmanager.appsettings["TimerInterval"], out itimerinterval);
Timer. Interval = Itimerinterval;
Timer. Elapsed + = new System.Timers.ElapsedEventHandler (getMessage);
GetMessage is a method (slightly)
}



The questioner adopts:


After your supplement, I see it. Because your application is recycled after a specific idle time, the corresponding W3WP worker process is not functioning anymore. You can view the properties of the IIS application pool switch to the Performance tab idle timeout default time is 20 minutes That is, if your site does not have any requests within 20 minutes, it will cause recycling.


-----------------------------------------------------------

WebService Timer timer in C # automatically stops running after a period of time

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.