SchedulerService class
Represents a service for managing scheduled tasks. Provides methods to schedule, cancel, pause, resume, and report on tasks. This service is designed to run within a Kestrun application context. It supports both C# and PowerShell jobs, allowing for flexible scheduling options.
public sealed class SchedulerService : IDisposable
parameter | description |
---|---|
pool | The runspace pool manager for executing PowerShell scripts. |
log | The logger instance for logging events. |
tz | The optional time zone information. |
Public Members
name | description |
---|---|
SchedulerService(…) | Represents a service for managing scheduled tasks. Provides methods to schedule, cancel, pause, resume, and report on tasks. This service is designed to run within a Kestrun application context. It supports both C# and PowerShell jobs, allowing for flexible scheduling options. |
Cancel(…) | Cancels a scheduled job by its name. |
CancelAll() | Cancels all scheduled jobs. |
CancelAsync(…) | Asynchronously cancels a scheduled job and optionally waits for its runner to complete. |
Dispose() | Disposes the scheduler and cancels all running tasks. |
GetReport(…) | Generates a report of all scheduled jobs, including their last and next run times, and suspension status. |
GetReportHashtable(…) | Generates a report of all scheduled jobs in a PowerShell-friendly hashtable format. |
GetSnapshot() | Gets a snapshot of all scheduled jobs with their current state. |
GetSnapshot(…) | Gets a snapshot of all scheduled jobs with their current state, optionally filtered and formatted. |
Pause(…) | Pauses a scheduled job by its name. |
Resume(…) | Resumes a scheduled job by its name. |
Schedule(…) | Schedules a C# job to run at a specified interval. (8 methods) |
ScheduleAsync(…) | Asynchronously schedules a script job from a file to run at a specified interval. (2 methods) |
Remarks
The service uses a runspace pool for PowerShell jobs and supports scheduling via cron expressions or intervals. It also provides methods to retrieve task reports in various formats, including typed objects and PowerShell-friendly hashtables.
Initializes a new instance of the SchedulerService
class. This constructor sets up the scheduler service with a specified runspace pool, logger, and optional time zone. The runspace pool is used for executing PowerShell scripts, while the logger is used for logging events.
See Also
- namespace Kestrun.Scheduling