kbmMW Scheduler Tidbits #4 -Relaxed vs precise recurrent jobs

The kbmMW Scheduler schedules jobs. The jobs may be one time or recurrent jobs.

Some jobs may not be critical related to the exactness of their executing time on the mSec (like generating a report, doing a backup, importing some data and other such housekeeping and maintenance), while others may require as accurate as possible execution, for example sampling data, screen grabbing or stuff like that.

The scheduler can do both.

When defining a recurrent job, you typically also tells it with which interval it should run. The scheduler contains multiple fluent expressions to define the interval, like EveryMinute, EveryHour, EveryDay, EverySecond, EveryMSecond etc. which all takes floating point values.

Hence you can easily schedule (and activate) a job to run every 1.5 hour, by writing this:

kbmMW default assumes that jobs scheduled with an interval less than 2 seconds should be considered “precise” jobs, while others should be considered “relaxed” jobs.

A “Relaxed” job is a job, that is being assigned a thread from a thread pool, when it’s about to execute. If there are no threads available, the job is put on hold until a thread is free.

Thus Relaxed jobs often share one or a few threads to run, and thus are very gentle to the system resources. But the downside is that they may not execute completely on time. Their execution may be delayed a few mSecs to even minutes or hours, depending on the available number of threads in the relaxed thread pool, and the load of the scheduled relaxed jobs. Typically any delays will be minimal, but there is no guarantee.

A “Precise” job is a job that from time of defining the job, will have its own thread assigned to it, and thus will run independently of all other jobs.

As mentioned kbmMW automatically decides, upon scheduling time, which mode the job is to take, relaxed or precise. But you can override this manually by specifically stating either Relaxed or Precise as part of the fluent expression. E.g.


In a previous Scheduler Tidbit blog post, I mentioned the new CronTab scheduling style. Since UNIX cron only has an interval resolution of 1 minute, scheduling such a job using kbmMW’s scheduler also will predefine the use of a one minute interval, and thus all cron jobs will default be scheduled as relaxed jobs.

However you can choose a different interval resolution by using any of the Every…. fluent expressions before the Cron expression. Eg.

If you state the Every… expression after the Cron expression, it will add to the default 1 minute cron schedule. Eg.

kbmMW Scheduler Tidbits #1 – Async methods

kbmMW Scheduler Tidbits #2 – CRON

kbmMW Scheduler Tidbits #3 – Handling delays

 19,871 total views,  28 views today

Author: kimbomadsen

3 thoughts on “kbmMW Scheduler Tidbits #4 -Relaxed vs precise recurrent jobs

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.