Class BatchTaskFactory
Factory for dealing with batch tasks. Tasks are identified by a unique name and might require a context.
Implements
Inherited Members
Namespace: SuperOffice.CRM.BatchProcessing
Assembly: SoBatchProcessing.dll
Syntax
public class BatchTaskFactory : IBatchTaskFactory
Constructors
BatchTaskFactory(ILogger<BatchTaskFactory>)
Factory for dealing with batch tasks. Tasks are identified by a unique name and might require a context.
Declaration
public BatchTaskFactory(ILogger<BatchTaskFactory> logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger<BatchTaskFactory> | logger |
Methods
EndTaskAsync(int, CancellationToken)
Signal an executing task to end execution.
Declaration
public Task EndTaskAsync(int taskId, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id of the task to end. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
GetRunningTasks(BatchTaskState, bool?, bool?)
Returns array of running tasks in a given state.
Declaration
public BatchTaskInfo[] GetRunningTasks(BatchTaskState state = 99999, bool? internalTasks = null, bool? systemTasks = null)
Parameters
Type | Name | Description |
---|---|---|
BatchTaskState | state | Only return tasks in this state |
bool? | internalTasks | |
bool? | systemTasks |
Returns
Type | Description |
---|---|
BatchTaskInfo[] | Array of running task info |
GetTaskInfo(int)
Obtain current information about the task.
Declaration
public BatchTaskInfo GetTaskInfo(int taskId)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id of the task to get Info for. |
Returns
Type | Description |
---|---|
BatchTaskInfo |
PurgeOldFinishedTasks(TimeSpan)
Purge outdated task information from the Factory
Declaration
public void PurgeOldFinishedTasks(TimeSpan timeSinceLastUpdate)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeSinceLastUpdate | How old information do you want to keep |
RunTaskAsync(BatchTaskInfo, string, CancellationToken)
Run the task with the given context.
Declaration
public Task RunTaskAsync(BatchTaskInfo batchTaskInfo, string context, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
BatchTaskInfo | batchTaskInfo | |
string | context | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
WaitForTaskCompletionAsync(int, CancellationToken)
Wait for the task to complete.
Declaration
public Task<BatchTaskInfo> WaitForTaskCompletionAsync(int taskId, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id of task to wait for. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<BatchTaskInfo> | Information about the completed task. |