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 7807649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:54:58+00:00 2026-06-02T02:54:58+00:00

I am trying to retrieve the data from MSSQL and PostrgeSQL databases to populate

  • 0

I am trying to retrieve the data from MSSQL and PostrgeSQL databases to populate it into a MySQL database on a regular basis (every hour).

Based on a research I’ve done, I would like to use a C# Timer to do that. However, I do not fully understand the way timer works.
I declare it in the Page_Load, set the elapsed event handler and call a method from the event handler.

protected void Page_Load(object sender, EventArgs e)
{
    int duration = 100 * 60 * 5; //milliseconds * seconds * minutes

    // Create a timer with a two second interval.
    System.Timers.Timer timer = new System.Timers.Timer(duration);

    // Hook up the Elapsed event for the timer.
    timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);

    timer.Enabled = true;
}

void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
    cf();
}

This works, but…

The problem is that this way the timer is being initialized every time the page is loaded. How do I create a timer which is initialized only once and keeps running from that moment without being reinitialized. Also, how do I handle the situation if the timer or a method fails – throws an exception, or a server goes down? How do I restart the timer then?

Any insight would help! Thank you in advance!

  • 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-02T02:54:59+00:00Added an answer on June 2, 2026 at 2:54 am

    You do not want to do this on a ASP.NET Web Page. The ASP.NET timer is designed for actions to occurs during the lifetime of a page before you navigate away.

    IF you want to do long running work like this (i.e. a task once-per-hour 24/7) you would be much better off either:

    • using an always on Windows Service with a System.Timer or
    • using a Windows Scheduled Task with a 1-per-hour schedule, which kicks off a Console Application.

    Another option, since you’re task seems to be heavily related to database data transfer would be to use something like SSIS or another alternative ETL Tool (Extract-Transform-Load)

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

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to retrieve specific data from my MySQL database by passing the
I'm trying to retrieve record data from an MS-Access database and store it into
I am trying to figure out how to retrieve data from a MySQL database
Hi i am trying to retrieve data from mysql database to create flot graph
I am trying to populate a text field with data from a MySQL database,
I'm trying to retrieve data from an SQL Server 2000 server, and place into
I am trying to retrieve data from mysql then display it on android listview.
I am trying to transfer a table from MySQL to MSSQL using the data
I am trying to retrieve data from MySQL for a flash application via PHP,

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.