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 class AgentTaskSchedulerService : BackgroundService, IHostedService, IDisposable

Inheritance

Implements

Inherited Members

Constructors

AgentTaskSchedulerService(IServiceProvider, NotificationHub<TaskStatusUpdate>, ILogger<AgentTaskSchedulerService>)

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

Methods

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.

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.