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
Inherited Members
Namespace: LemonEdge.Client.Core.Tasks
Assembly: LemonEdge.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 |
---|---|---|
CancellationTokenSource | cancelSource | The cancellation token indicating the task has been cancelled by the user |
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 |
---|---|
CancellationToken |
CurrentStatus
Returns the current status of the underlying task being tracked
Declaration
public ServerTaskStatusEnum CurrentStatus { get; }
Property Value
Type | Description |
---|---|
ServerTaskStatusEnum |
Header
Returns the header of the task being tracked
Declaration
public string Header { get; }
Property Value
Type | Description |
---|---|
string |
MaxProgressIndex
Indicates the maximum progress index used for reporting by the task so far
Declaration
public short MaxProgressIndex { get; }
Property Value
Type | Description |
---|---|
short |
Name
Returns the name of the task being tracked
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
RunningOnServer
False - this tracker only tracks tasks executing locally
Declaration
public bool RunningOnServer { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
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 |
---|---|
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 |
---|---|
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 |
---|---|
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 |
---|---|
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 |
---|---|
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 |
---|---|
Task<IEnumerable<ITaskMessage>> | The history of all progress messages for all indexes for the specified message type |
GetAllProgressMesssages(short)
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 |
---|---|---|
short | progressIndex | The index of the messages to report |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITaskMessage>> | The history of all progress messages for the specified index for the task so far |
GetCurrentProgress(short)
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 |
---|---|---|
short | progressIndex | The index of the progress to report |
Returns
Type | Description |
---|---|
decimal | The current progress of the specified index |
GetProgressCurrentMessage(short)
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 |
---|---|---|
short | progressIndex | The index of the message to report |
Returns
Type | Description |
---|---|
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 |
---|---|---|
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 |
---|---|---|
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 |
---|---|---|
decimal | progressPercent | The current progress of the overall operation |
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 |
---|---|---|
string | msg | The header for the current state of progress |
ReportProgressWithForceSave(decimal, string)
Reports the percentage progress on the current overall operation with a specific message
Declaration
public void ReportProgressWithForceSave(decimal progressPercent, string message = "")
Parameters
Type | Name | Description |
---|---|---|
decimal | progressPercent | The current progress of the overall operation |
string | message | The message for the current progress |
ReportSubProgress(short, 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 |
---|---|---|
short | subProgressIndex | The index of the current sub task. Sub tasks should start at 1 and increment for each sub task. |
decimal | progressPercent | The progress of the current sub task |
string | message | The message for the current progress of the sub task |
SetStatus(ServerTaskStatusEnum)
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(ServerTaskStatusEnum status)
Parameters
Type | Name | Description |
---|---|---|
ServerTaskStatusEnum | 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 |
---|---|
EventHandler<EventArgs> |