Class BackgroundWorker
Implements a simple worker to do work in the background. Calls the backgroundworker events 'DoWork' and 'RunWorkerCompleted'. Does not support cancellation. Sets the Parameter property of the WorkerResult which is the parameter of the response method to the RunWorkerCompletedEventArgs. Sets the Exception property of the WorkerResult which is the parameter of the response method to the RunWorkerCompletedEventArgs.Error so that the developer can handle the exception in the response method.
Inheritance
Implements
Namespace: Sartorius.SAF.Threading
Assembly: Sartorius.SAF.dll
Syntax
[Export(typeof(IBackgroundWorker))]
public class BackgroundWorker : IBackgroundWorker
Methods
View SourceDoWork(Action, Action<WorkerResult>)
Does the given work
in the background. When the work is done, the response
is invoked, if exists.
Declaration
public void DoWork(Action work, Action<WorkerResult> response)
Parameters
Type | Name | Description |
---|---|---|
System.Action | work | The work to be done. |
System.Action<WorkerResult> | response | The response action that is invoked when the work is done. |
DoWork<T>(Func<T>, Action<WorkerResult<T>>)
Does the given work
in the background. When the work is done, the response
is invoked.
Declaration
public void DoWork<T>(Func<T> work, Action<WorkerResult<T>> response)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T> | work | The work to be done. The result value of |
System.Action<WorkerResult<T>> | response | The response action that is invoked when the work is done. The result value of |
Type Parameters
Name | Description |
---|---|
T |