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 : IDisposable
Methods
Dispose()
Factory for dealing with batch tasks. Tasks are identified by a unique name and might require a context.
Declaration
public void Dispose()
EndTask(int)
Signal an executing task to end execution.
Declaration
public void EndTask(int taskId)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id of the task to end. |
GetCurrent()
Factory for dealing with batch tasks. Tasks are identified by a unique name and might require a context.
Declaration
public static BatchTaskFactory GetCurrent()
Returns
Type | Description |
---|---|
BatchTaskFactory |
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 |
IsTaskCompleted(int)
Check if the task has completed.
Declaration
public bool IsTaskCompleted(int taskId)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id if task to check if it has completed. |
Returns
Type | Description |
---|---|
bool | True if the task has completed. |
Remarks
Use GetTaskInfo(int) to get information about the state of the task.
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 |
StartTask(BatchTaskInfo, string)
Factory for dealing with batch tasks. Tasks are identified by a unique name and might require a context.
Declaration
public BatchTaskInfo StartTask(BatchTaskInfo batchTaskInfo, string context)
Parameters
Type | Name | Description |
---|---|---|
BatchTaskInfo | batchTaskInfo | |
string | context |
Returns
Type | Description |
---|---|
BatchTaskInfo |
StartTask(string, string)
Start executing an internal (in-memory) task a asynchronously.
Declaration
[Obsolete("Internal tasks not supported", false)]
public BatchTaskInfo StartTask(string name, string context)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the task to execute. |
string | context | Context for the task. |
Returns
Type | Description |
---|---|
BatchTaskInfo | Information about the task. |
Exceptions
Type | Condition |
---|---|
SoIllegalOperationException | Thrown if the task is not found. |
WaitForTaskCompletion(int)
Wait infinitely for the task to complete.
Declaration
public BatchTaskInfo WaitForTaskCompletion(int taskId)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id of task to wait for. |
Returns
Type | Description |
---|---|
BatchTaskInfo | Information about the completed task. |
WaitForTaskCompletion(int, int)
Wait for the task to complete.
Declaration
public BatchTaskInfo WaitForTaskCompletion(int taskId, int timeOut)
Parameters
Type | Name | Description |
---|---|---|
int | taskId | Id of task to wait for. |
int | timeOut | Timeout in seconds to wait. Values less than 1 is considered to be infinite. |
Returns
Type | Description |
---|---|
BatchTaskInfo |
Remarks
If the task is not completed withing the time frame specified, a SoException is thrown.
Exceptions
Type | Condition |
---|---|
SoException | Thrown if the task does not complete within the time frame specified in the timeout value. |