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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:08:22+00:00 2026-06-18T03:08:22+00:00

I need to write a windows service which performs the same operations every X

  • 0

I need to write a windows service which performs the same operations every X minutes.
What is the best way to achieve this, with respect to memory management (e.g. allowing the GC to clean up)

1) while(true) loop, with my own logic to ensure the operation only occurs every X minutes. I am worried this will block the GC from cleaning up however.

2) Timer, with some logic to make sure if the operation takes longer than the timer interval it does start performing it twice at the same time (more complicated that 1)

3) Other suggestions?

  • 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-18T03:08:23+00:00Added an answer on June 18, 2026 at 3:08 am

    In both (1) and (2) there is no reason to worry about GC.

    (1) is okay if my own logic doesn’t boil down to busy loop (which would use CPU for no reason). The easiest way to implement that logic is to Sleep for X minutes.

    (2) is preferable if it’s important for the task to begin regularly: e.g. given the interval of 15 minutes and the start at 0:00, the next task should begin at 0:15, the next at 0:30, and so on, not “discounting” the time elapsed while doing the task.

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

Sidebar

Related Questions

I need to write a windows service which executes an application after a certain
If we need to write a program that works periodically, which way do we
I need a way to exchange data between a process and a windows service.
I'm writing a program, which creates Windows service. So I need two .exe files
I need to write a program in .NET which runs every few hours and
we are trying to write a service for windows and need to come up
I need to write an SNMP agent on Windows for our company product. SnmpApi.lib
I need to write Hebrew text in Latex. I am currently working on Windows
I have some text to write to the Windows console that I need to
I need to share a folder with read and write permissions . In windows

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.