Skip to content

ITaskRunner

Interface in Oadm.Sdk.Tasks · Oadm.Sdk.dll

Starts and cancels tasks from a core plugin (ICorePluginContext.Tasks).

public interface ITaskRunner

Guide: Core plugins and pages

Task<bool?> AnyActiveAsync(IReadOnlyCollection<Guid> taskIds, CancellationToken ct)

Default implementation

Whether any of the tasks is still queued or running: true when one is, false when none is, null when the host cannot tell (SDK 0.4.0). On ICallContext.Tasks of a user with a device group it answers for the tasks of the devices in the user’s view, whichever user started them (ITaskRunner.IsActive answers only the user’s own); a task on a device outside the view makes the answer null. The default asks ITaskRunner.IsActive per task.

bool Cancel(Guid taskId)

Default implementation

Requests cancellation of a task (queued: ends Cancelled before start; running: its token is cancelled). Returns false when the task is not active or the host cannot cancel.

Task<TaskOutcome?> GetOutcomeAsync(Guid taskId, CancellationToken ct)

Default implementation

How the task ended and its message as the tasks pane shows it (SDK 0.7.0): the error of a failed task, the warning of one done with warnings. Null while it is queued or running, for an unknown task, and when the host cannot tell. On ICallContext.Tasks of a user with a device group it answers like ITaskRunner.AnyActiveAsync: for the tasks of devices in the user’s view, null for the others. Default (older hosts): null.

bool? IsActive(Guid taskId)

Default implementation

Whether the task is still queued or running; null when the host cannot tell. A task cancelled while queued never starts, so a plugin waiting for its tasks asks here instead of waiting for them to report.

Task<IReadOnlyList<Guid>> RunAsync(string pluginId, IReadOnlyList<Guid> deviceIds, string? payloadJson, string owner, CancellationToken ct)

Runs a task plugin on the given devices: one task per device (all sharing one batch id), so one failing device never affects the others. Returns the task ids in device order.

Task<IReadOnlyList<Guid>> RunAsync(string pluginId, IReadOnlyList<Guid> deviceIds, string? payloadJson, string owner, TaskAudit audit, CancellationToken ct)

Default implementation

SDK 0.15.0: runs like ITaskRunner.RunAsync and writes the audit entry “Started task” for the run (audit): the device count while it runs, the outcome once every task of the run has ended (how many done, done with warnings, failed, cancelled, the first failures). Default (older hosts): the run without an entry.