Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8760837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:08:35+00:00 2026-06-13T15:08:35+00:00

Background: I have a .NET 4.0 web service running on Windows Server 2008 written

  • 0

Background:
I have a .NET 4.0 web service running on Windows Server 2008 written in C#.
I would like to run a timer inside the asp.net web service that runs code once a day. I have heard of some limitations with this (see below) but I am asking if what I plan is OK in order to get around some of the limitations and to keep the code inside the web service as it is not mission critical code. However a crash is unacceptable. Note: I am not and can not use WCF.

The plan:

  • Declare and instantiate System.Threading.Timer in the constructor of
    my web service (right next to the commented out line:
    //InitializeComponent(); ).
  • Fire timer every 30 minutes.
  • Note: Because I am using System.Threading.Timer I should not have to run
    keep-alive code according to msdn Tip #6 below.
  • IF the current time
    is within 30 minutes of my database value (desired time to run code)
    THEN run code.

Questions:

  • I would like to know how reliable it is to use System.Threading.Timer in asp.net c# code using the plan above and if it would run correctly let’s say more than 97% of the time?
  • Will this plan work when the app pool is recycled and when IIS server is restarted?

It seems there are issues using timers in web services with regards to:

  • app pool recycling
  • threads dying
  • no one hits web for a long period
  • of time memory issues (better to use windows service)

References:

ASP.NET Site – Firing some code at a specific time

Timer on Website to activate Web Service calls every hour

http://forums.asp.net/t/1079158.aspx/1

http://msdn.microsoft.com/en-us/magazine/cc163854.aspx (see Tip #6)

From Tip #6
“The Timer class, found in the System.Threading namespace, is a wonderfully useful, but less well-known class in the .NET Framework, at least for Web developers. Once created, the Timer will invoke the specified callback on a thread from the ThreadPool at a configurable interval. This means you can set up code to execute without an incoming request to your ASP.NET application, an ideal situation for background processing. You can do work such as indexing or sending e-mail in this background process too.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:08:36+00:00Added an answer on June 13, 2026 at 3:08 pm

    You’re using the wrong tool for the job. Web Services are meant for on-demand use, while services and scheduled tasks should be used for periodic activities. Move the relevant code out of the web service into a shared library and then either create a Windows Service with a Timer or a Console App that can be scheduled through Scheduled Tasks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have created a .NET 4 web service, which runs fine on a Windows
Background We have an asp.net 4.0 web application written in C# that calls a
Background - Visual Studio 2010, C#, .Net Framework 4.0 application I have a web
I have a background service running which sends out emails to users of my
i'm creating asmx web service and have to create thread to do background IO
I have built a C# .net web service that takes a complex type as
I have a web service created using Apache CXF, and two .NET clients using
First a bit of background: I have a web server which runs 4 instances
Background: I have a winform application written in VB.NET that uses a WebService to
First some background: I have a website using ASP.NET web forms + jQuery 1.6.4

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.