Start a job or schedule it in standard threadPool with monitoring and cancelation TasksOnTime Can be used in service , console, website or wpf/winforms applications
Require only .Net 4.5.2 (minimum) with no other dependance or Require only dotnetcore 3.0
First, install Nuget then, install TasksOnTime from the package manager console.
PM> Install-Package TasksOnTime
Each Task must implement ITask interface
public interface ITask
{
void Execute(ExecutionContext context);
}
public class MyTask : ITask
{
public void Execute(ExecutionContext context)
{
System.Diagnostics.Debug.WriteLine("Task executed");
}
}
TasksHost.Enqueue<MyTask>();
TasksHost.Enqueue<MyTask>(delayInMillisecond: 5 * 1000);
See others examples :
For use scheduled tasks add assembly reference "TasksOnTime.Scheduling" in your project . Each task can scheduled by month, day, hour, minute or second with interval as you like. Each scheduled task can be canceled, removed or forced , each task was executed in standard threadpool. Single instance of scheduler was possible by application.
PM> Install-Package TasksOnTime.Scheduling
Task implements ITask
var scheduledTask = TasksOnTime.Scheduler.CreateScheduledTask<MyTask>("MyTask")
.EveryMinute();
TasksOnTime.Scheduler.Add(scheduledTask);
TasksOnTime.Scheduler.Start();
...
TasksOnTime.Scheduler.Stop();
See others examples :