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

  • Home
  • SEARCH
  • 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 8737619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:34:03+00:00 2026-06-13T10:34:03+00:00

I have created an application that is used to read a mail box at

  • 0

I have created an application that is used to read a mail box at certain intervals. If there is a new mail it downloads the attachment creates pdf files say 100 + combines it and mail it back to a particular list. Due to some server policies am in a position to convert it to a window service. I have used a timer my code given below

private System.Threading.Timer timer;
timer = new System.Threading.Timer(TimerTick, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));

void TimerTick(object state)
{
  var minute = DateTime.Now.Minute;
  if (minute != lastMinute && minute % 5 == 0)
  {
    //check mail here
  }
}

Is implementing a timer like this an efficient way of doing this? Is there any better way to handle this? I am worried about the performance because the applications need to run 24 x7 and hence can end up in utilizing more cpu memory if inefficient.

is timer the only best available option in this scenario ?

  • 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-13T10:34:04+00:00Added an answer on June 13, 2026 at 10:34 am

    You should monitor you service for performance. If you see there a performance problem:

    1. measure it
    2. change your code
    3. measure again
    4. than compare your measurments

    System.Threading.Timer is a simple, lightweight timer that uses callback methods and is served by threadpool threads.

    • You might consider System.Timers.Timer for server-based timer
      functionality.

    Maintainability and debug tips:

    • Use a XML config file to set the interval, without change your code.
      This will simply give you or administrators control about the service.

    Use the code for easy debugging your service:

    static void Main()
    {
    #if (!DEBUG)
        System.ServiceProcess.ServiceBase[] ServicesToRun;
        ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service1() };
        System.ServiceProcess.ServiceBase.Run(ServicesToRun);
    #else
        // Debug code: this allows the process to run as a non-service.
        // It will kick off the service start point, but never kill it.
        // Shut down the debugger to exit
        Service1 service = new Service1();
        service.EntryMethodHere(); // Your method that activates your timer
        // Put a breakpoint on the following line to always catch
        // your service when it has finished its work
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    #endif 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application that creates bar graph based on inputs read from
I have created one application in j2me, I have used json parsing in that
I have created a Java application that has 2 Jar files. Jar1 is used
I have created an application that connect on a web-server and reads an xml
I have created an application that uses settings.settings to store some user specific settings
I have created an application that records a series of longitude and latitude values
I have a problem regarding Android App. I have created an application that download
I have created an android application that calls (using kSOAP library) a SOAP based
I have created one application in flex that is accessing the Java webservice using
I have created an application server side that will create a pdf of a

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.