Class ClientTaskProgressDisplayer
An implementation of ITaskStatusDisplayer used for monitoring locally executing tasks and being able to display them in the client application.
This tracker implements the IProgressReporter which is used by the locally executing task, meaning as the task updates its progress it is in fact automatically updating this trackers display of the tasks progress
Inheritance
Inherited Members
Namespace: LemonEdge.Client.Core.Tasks
Assembly: ClientCore.dll
Syntax
public class ClientTaskProgressDisplayer : ITaskStatusDisplayer, IProgressReporter
Constructors
ClientTaskProgressDisplayer(CancellationTokenSource, String)
Creates a new client displayer with the specified cancellation token and header name for the task being tracked
The caller uses the cancellation task and the IProgressReporter this class implements for executing the tracked task
Declaration
public ClientTaskProgressDisplayer(CancellationTokenSource cancelSource, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationTokenSource | cancelSource | The cancellation token indicating the task has been cancelled by the user |
| System.String | name | The name of the task being tracked |
Properties
CancelToken
The token used to indicate the task has been cancelled
Declaration
public CancellationToken CancelToken { get; }
Property Value
| Type | Description |
|---|---|
| System.Threading.CancellationToken |
CurrentStatus
Returns the current status of the underlying task being tracked
Declaration
public ServerTaskStatus CurrentStatus { get; }
Property Value
| Type | Description |
|---|---|
| ServerTaskStatus |
Header
Returns the header of the task being tracked
Declaration
public string Header { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
MaxProgressIndex
Indicates the maximum progress index used for reporting by the task so far
Declaration
public short MaxProgressIndex { get; }
Property Value
| Type | Description |
|---|---|
| System.Int16 |
Name
Returns the name of the task being tracked
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
RunningOnServer
False - this tracker only tracks tasks executing locally
Declaration
public bool RunningOnServer { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ServerTaskID
Returns the unique ID of the IServerTask being tracked.
Can be null if this isn't tracking a single task but is actually tracking multiple tasks
Declaration
public Guid? ServerTaskID { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Guid> |
TimeRunning
A user friendly message of how long the task took to run, or how long it has currenty been running for
Declaration
public string TimeRunning { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Tooltip
A user friendly tooltip for the currently tracked task containing header info, status and the percentage progress
Declaration
public string Tooltip { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
BasicInfo(ITaskStatusDisplayer)
Returns user friendly information for the specified tracked executing task that can be used as a tooltip or other overview
Declaration
public static string BasicInfo(ITaskStatusDisplayer displayer)
Parameters
| Type | Name | Description |
|---|---|---|
| ITaskStatusDisplayer | displayer | The tracked executing task to return user friendly for |
Returns
| Type | Description |
|---|---|
| System.String | A user friendly information for the specified tracked executing task that can be used as a tooltip or other overview |
Cancel()
Cancel the task (or all tasks) being tracked by setting Cancel to true
Declaration
public Task Cancel()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task indicating the completion of the message. This only indicates the task is being set to cancel, the task itself still needs to respond to the request |
FlushAllPendingMessages()
Nothing to do here for displayer as messages are displayed on ui to user, so no pending to flush
Declaration
public Task FlushAllPendingMessages()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | Returns a completed task |
GetAllMessages(TaskMessageType)
Returns the history of all progress messages for all indexes for the specified message type
Declaration
public Task<IEnumerable<ITaskMessage>> GetAllMessages(TaskMessageType type)
Parameters
| Type | Name | Description |
|---|---|---|
| TaskMessageType | type | The type of reported messages to return |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ITaskMessage>> | The history of all progress messages for all indexes for the specified message type |
GetAllProgressMesssages(Int16)
Returns the history of all progress messages for the specified index for the task so far
Declaration
public Task<IEnumerable<ITaskMessage>> GetAllProgressMesssages(short progressIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int16 | progressIndex | The index of the messages to report |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ITaskMessage>> | The history of all progress messages for the specified index for the task so far |
GetCurrentProgress(Int16)
Returns the current progress for the specified index. The default, or main progress, is reported with an index of 0.
See IProgressReporter for more information
Declaration
public decimal GetCurrentProgress(short progressIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int16 | progressIndex | The index of the progress to report |
Returns
| Type | Description |
|---|---|
| System.Decimal | The current progress of the specified index |
GetProgressCurrentMessage(Int16)
Returns the current message/status associated with the current progress for the specified index. The default, or main progress, is reported with an index of 0.
See IProgressReporter for more information
Declaration
public string GetProgressCurrentMessage(short progressIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int16 | progressIndex | The index of the message to report |
Returns
| Type | Description |
|---|---|
| System.String | The current message/staus for the associated progress of the specified index |
ReportError(Exception)
Reports an error encountered at the current percentage progress
Declaration
public void ReportError(Exception ex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Exception | ex | The exception encountered during the operation |
ReportMessage(String)
Reports a message for the current progress
Declaration
public void ReportMessage(string message)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | message | The message to display |
ReportProgress(Decimal, String)
Reports the percentage progress on the current overall operation with a specific message
Declaration
public void ReportProgress(decimal progressPercent, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.Decimal | progressPercent | The current progress of the overall operation |
| System.String | message | The message for the current progress |
ReportProgressHeader(String)
Reports the overall header for the current progress state
Declaration
public void ReportProgressHeader(string msg)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | msg | The header for the current state of progress |
ReportSubProgress(Int16, Decimal, String)
Reports the percentage progress for the current sub task of the overall operation with a specific message
Declaration
public void ReportSubProgress(short subProgressIndex, decimal progressPercent, string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int16 | subProgressIndex | The index of the current sub task. Sub tasks should start at 1 and increment for each sub task. |
| System.Decimal | progressPercent | The progress of the current sub task |
| System.String | message | The message for the current progress of the sub task |
SetStatus(ServerTaskStatus)
Sets the status reported by this task displayed to the specified value and raises the LemonEdge.Client.Core.Tasks.ClientTaskProgressDisplayer.NotifyStatusChanged event
Declaration
public void SetStatus(ServerTaskStatus status)
Parameters
| Type | Name | Description |
|---|---|---|
| ServerTaskStatus | status | The status to report for this tracked task |
Events
OnStatusChanged
Indicates the status of the task being tracked has changed, so the UI has chance to reflect this
Declaration
public event EventHandler<EventArgs> OnStatusChanged
Event Type
| Type | Description |
|---|---|
| System.EventHandler<System.EventArgs> |