Table of Contents

Class AgentTaskSchedulerService

Namespace
Oscova.Agents.Tasks
Assembly
Oscova.Agents.dll

Background scheduler that starts enabled agent tasks when their schedules become due.

public sealed class AgentTaskSchedulerService : BackgroundService, IHostedService, IDisposable

Inheritance

Implements

Inherited Members

Constructors

AgentTaskSchedulerService(IServiceProvider, NotificationHub<TaskStatusUpdate>, ILogger<AgentTaskSchedulerService>, TimeProvider, Func<AgentTaskDefinition, CancellationToken, Task<bool>>?, Func<string, bool>?)

Background scheduler that starts enabled agent tasks when their schedules become due.

Methods

CancelAndAcquireUserAsync(string, CancellationToken)

Cancels and drains a user's task executions while blocking new starts until cleanup finishes.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

ExecuteAsync(CancellationToken)

This method is called when the Microsoft.Extensions.Hosting.IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

ForgetLastRun(string, string, string)

Forgets the tracked last run when it is the deleted run, so run lists do not show it again.

GetRunningTasks(string)

Gets currently running task runs.

IsTaskRunning(string, string)

Returns whether a task currently has an active running entry.

RunTaskDeletionAsync(string, string, Func<CancellationToken, Task<bool>>, CancellationToken, Func<CancellationToken, Task>?)

Cancels a task and keeps its admission closed while its definition is deleted.

RunTaskSaveAsync(string, string, Func<CancellationToken, Task<AgentTaskDefinition?>>, CancellationToken)

Persists a task definition and reopens admission only when the callback saved it.

StopAsync(CancellationToken)

Triggered when the application host is performing a graceful shutdown.

TriggerTaskAsync(AgentTaskDefinition, TaskTriggerSource, IReadOnlyDictionary<string, JsonElement>?, CancellationToken)

Queues an enabled task for immediate manual execution if it is not already running.

TryGetLastRun(string, string, out AgentTaskRun?)

Returns the most recent run for a task, whether currently running or completed, as long as it has not been replaced by a newer run. Returns false if no run has started since the last app restart.