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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:03:10+00:00 2026-05-31T07:03:10+00:00

I have a Windows service that continuously performs calculation tasks. There are multiple calculation

  • 0

I have a Windows service that continuously performs calculation tasks. There are multiple calculation steps performed as part of a single calculation task.

This service is required to log/track the calculation tasks and steps so that multiple clients can poll and observe the activity.

To meet this requirement, I’ve added a simple Dictionary<Guid, List<string>> (_activity) to my service that collects the activity messages. The key is a Guid representing the CalculationTask.Id, and the value is a List<string> holding the messages from the individual calculation steps.

I naively added a method to the service that is invoked by the clients (via wcf) to poll for activity messages. The client would pass in a lastPolledTimeStamp in an attempt to tell the service, “give me all of your messages since I last polled“…

private readonly Dictionary<Guid, List<string>> _activity = new Dictionary<Guid, List<string>>();
public List<string> GetActivity(DateTime lastPolledTimeStamp)
{
   var snapshot = _activity.ToList();

   return snapshot.SelectMany(x => x.Value)
      .Where(x => x.TimeStamp > lastPolledTimeStamp)
      .OrderBy(x => x.TimeStamp)
      .ToList();
}

Here are my problems and questions:

(1) When the client and service are on different machines, attempts to filter the results by date/time comparisons will not work. And I can’t simply return everything in _activity each time GetActivity is called – there’s too much data. There has to be some sort of filtering. What other options do I have?

(2) Another “problem” is knowing when an a key/value pair in the _activity dictionary can be removed. The clients are polling every 5 seconds. I want to keep the key/value pair around long enough so that clients have a chance to pick it up… Perhaps I should include another timer that executes to periodically clean up the old entries in _activity. Thoughts?

  • 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-05-31T07:03:12+00:00Added an answer on May 31, 2026 at 7:03 am

    For your first problem, return the server’s time with each response, and get the client to send this timestamp, rather than their own time, when making a request.

    For the second problem: if the calculations/steps may be producing messages at different rates, rather than have a fixed-size buffer for each set of updates, I’d stick with running a cleanup job every so often, deleting messages older than [a small multiple of the client’s ping interval].

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

Sidebar

Related Questions

I have a Windows service that runs implementations of a framework across multiple threads.
I have a windows service that loads multiple handlers written by different developers. The
I have a windows Service that start some tasks based on a configuration. Each
I have a windows service that runs various system monitoring operations. However, when running
I have a windows service that runs fine, but I have to have it
I have a windows service that has a custom configuration section. In the configSectionHandler
I have a Windows service that runs as a logged-in user (local admin). During
I have a Windows Service that takes the name of a bunch of files
I have a windows service that generates logs as it does some execution. I
I have a windows service that receives a large amount of data that needs

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.