public class RecurringTaskScheduler extends Object implements IDisposable
| Constructor and Description |
|---|
RecurringTaskScheduler()
Initializes a new instance.
|
RecurringTaskScheduler(int numberOfThreads)
Initializes a new instance to use a specified number of threads.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTask(Duration period,
RecurringTask task)
Adds a task to be executed on a recurring basis.
|
void |
dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting
unmanaged resources.
|
boolean |
getIsRunning()
Gets a value indicating if the scheduler in running.
|
int |
getNumberOfThreads()
Gets the number of threads used to execute the recurring tasks.
|
int |
getTaskCount()
Gets the number of tasks.
|
RecurringTaskStatistics |
getTaskData(RecurringTask task)
Gets a copy of the performance metrics associated with the given
recurring task.
|
Iterable<RecurringTask> |
getTasks()
Gets the list of tasks.
|
RecurringTaskStatistics |
removeTask(RecurringTask task)
Removes a task so that it is no longer executed on a recurring basis.
|
void |
start()
Starts running the scheduler.
|
void |
stop()
Stops running the scheduler.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic RecurringTaskScheduler()
ThreadingPolicy.public RecurringTaskScheduler(int numberOfThreads)
numberOfThreads - The number of threads to use to run tasks.ArgumentOutOfRangeException - Thrown if the value of numberOfThreads is
less than 1.public final void start()
NumberOfThreads (get) threads
have been started.IllegalStateException - Thrown if the scheduler is already running.public final boolean getIsRunning()
public final void stop()
InterruptedExceptionIllegalStateException - Thrown if the scheduler is not running.public void dispose()
IDisposabledispose in interface IDisposablepublic final int getNumberOfThreads()
public final void addTask(Duration period, RecurringTask task)
period - The period at which to execute the task.task - The task to add.ArgumentNullException - Thrown if task is null.public final RecurringTaskStatistics removeTask(RecurringTask task)
task - The task to remove.ArgumentNullException - Thrown if task is null.ArgumentException - Thrown if task was never added to the
scheduler.public final int getTaskCount()
public final Iterable<RecurringTask> getTasks()
public final RecurringTaskStatistics getTaskData(RecurringTask task)
ArgumentNullException - Thrown if task is null.ArgumentException - Thrown if task was never added to the
scheduler.