Class JobRunner
Provides a loop that checks its jobs at an interval and runs the ready ones, a few at a time.
public class JobRunner
- Inheritance
-
JobRunner
- Inherited Members
Remarks
It holds its jobs weakly: a job no one else references is dropped, and logged at Debug. Its loop runs for the process's life.
Constructors
JobRunner(TimeSpan)
Initializes a new instance of the JobRunner class and starts its loop.
public JobRunner(TimeSpan interval)
Parameters
intervalTimeSpanHow often the runner checks its jobs.
Exceptions
- ArgumentOutOfRangeException
The interval is not a timer's valid period.
Properties
FastInstance
Gets the shared runner that checks its jobs every 2 seconds.
public static JobRunner FastInstance { get; }
Property Value
Interval
Gets or sets how often the runner checks its jobs. A new interval restarts the countdown; the same one changes nothing.
public TimeSpan Interval { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The interval is not a timer's valid period.
Logger
Gets or sets the logger of the jobs' failures, or null for none. The default is the process's
VhLogger.Instance.
public ILogger? Logger { get; set; }
Property Value
MaxDegreeOfParallelism
Gets or sets how many jobs run at once. The default is 2.
public int MaxDegreeOfParallelism { get; set; }
Property Value
Remarks
A new value counts for the jobs started after it; the ones running then finish beside them.
Exceptions
- ArgumentOutOfRangeException
The value is less than 1.
SlowInstance
Gets the shared runner that checks its jobs every 10 seconds.
public static JobRunner SlowInstance { get; }
Property Value
Methods
Add(Job)
Adds a job, held weakly.
public void Add(Job job)
Parameters
jobJobThe job.
Remove(Job)
Removes a job.
public void Remove(Job job)
Parameters
jobJobThe job.