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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:22:25+00:00 2026-05-17T23:22:25+00:00

I am working on a Windows service which needs to schedule tasks whenever one

  • 0

I am working on a Windows service which needs to schedule tasks whenever one of it’s web services is called. This could happen hundreds of times per second in a worst case scenario. The task needs to wait a period of time, typically a minute or two, then call a method passing a parameter.

We tried to build our own scheduler class to do this:

public void ScheduleTask<T>(TimeSpan delay, Action<T> task, T arg)
{
    Thread.Sleep(delay);
    threadPool.ExecuteAsync(task, arg);
}

But we figured this wouldn’t be appropriate because we could theoretically end up with hundreds of Thread Pool threads all waiting. I am under the impression that there is a finite number of Thread Pool threads available and that this could potentially lock up the system.

I then turned to Quartz.NET and read on their features page that:

Job class instances can be instantiated by Quartz.NET, or by your application’s framework.

and on page 3 of their tutorial that the Scheduler creates instances of your Job class (not you) and as such:

it does not make sense to have data-members defined on the job class as their values would be ‘cleared’ every time the job executes.

Feel free to yell at me, but how do I get a reference to my Job class instance before it executes so I can set a property on it?

  • The property is doing the job of a
    parameter so i have no interest in it
    after the Job has executed.
  • I also want to minimise the number of
    objects it takes to acheive this to
    keep my code neat and simple.
  • Finally, I seriously dislike using
    Dictionaries so would prefer to avoid the JobDataMap object.
  • 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-17T23:22:26+00:00Added an answer on May 17, 2026 at 11:22 pm

    I don’t understand exactly what your use case is and why you would need to set a property on the job, but to answer your question: to get access to your job before it executes you need to create a job listener (implement IJobListener). The job listener gets called just before the job gets executed, so you could set a property at that point.

    Some links:
    The documentation on job listeners

    I wrote a blog post detailing the creation of listeners, here.

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

Sidebar

Related Questions

I'm working on Windows phone client for one service with Oauth1 API. In API
Overview: I'm working on some windows service using Visual Basic 2010, which deployed on
I've created a windows service that runs locally and provides a web service which
As I am working on one Windows service project, I am finding trouble to
I have modified a working Windows service that had always been starting beforehand. After
I'm working on a Windows Service that's having some issues with Thread.Sleep() so I
I'm working on creating a windows service that will send emails to a customer
I am posting XmlDocument to ApiController (from windows service, service is working fine, it
I have a service, as follows: The most basic (working) CherryPy 3.1 Windows service
I have a working WCF service. I want to deploy it on Windows Azure.

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.