C# Class GpsBroadcaster.Task

A class that represents a unit of work to be done. At the choice of the user, this can either be executed synchronously on the current thread or the GUI thread, or be executed asynchronously on a background worker. In either case, it will be able to report back on the GUI thread when the work is done. And if you choose to use an asynchronous operation, then it can also report back progress.
Show file Open project: bakacaptain/istalkapp

Private Properties

Property Type Description
Completed void

Public Methods

Method Description
BeginExecute ( ) : void

Method to start running this task asynchronously. This can only be used if the enum TaskHandler.Background was specified to the constructor of the class.

Cancel ( ) : void

This method cancels the task. This only works for TaskHandlers of type background.

Execute ( ) : void

Method to start running this task synchronously, either on the current thread or on the GUI thread. This can only be used if the enum TaskHandler.Dispatcher or TaskHandler.ThisThread was specified to the constructor.

Task ( Dispatcher dispatcher, TaskHandler handler ) : System

Constructor for the task.

Protected Methods

Method Description
Execute ( Object sender, DoWorkEventArgs args ) : void

Abstract method to be overridden that represents the work being done by the task.

ReportProgress ( Int32 percent, Object userState ) : void

Method used to report the progress being done by the task.

Private Methods

Method Description
Completed ( Object sender, RunWorkerCompletedEventArgs args ) : void

Method Details

BeginExecute() public method

Method to start running this task asynchronously. This can only be used if the enum TaskHandler.Background was specified to the constructor of the class.
public BeginExecute ( ) : void
return void

Cancel() public method

This method cancels the task. This only works for TaskHandlers of type background.
public Cancel ( ) : void
return void

Execute() public method

Method to start running this task synchronously, either on the current thread or on the GUI thread. This can only be used if the enum TaskHandler.Dispatcher or TaskHandler.ThisThread was specified to the constructor.
public Execute ( ) : void
return void

Execute() protected abstract method

Abstract method to be overridden that represents the work being done by the task.
protected abstract Execute ( Object sender, DoWorkEventArgs args ) : void
sender Object
args System.ComponentModel.DoWorkEventArgs
return void

ReportProgress() protected method

Method used to report the progress being done by the task.
protected ReportProgress ( Int32 percent, Object userState ) : void
percent System.Int32 An Int32 representing the progress.
userState Object An arbitary userState object to describe the state of the operation.
return void

Task() public method

Constructor for the task.
public Task ( Dispatcher dispatcher, TaskHandler handler ) : System
dispatcher System.Windows.Threading.Dispatcher
handler TaskHandler Is an enum representing how this task should be executed.
return System