Class BusyProgressReporter
A helper wrapper class that takes a IProgressReporter and/or IBusyReporter
Can pass interface calls to those underlying classes, and also ensures busy is set when progressing through a task
Inherited Members
Namespace: LemonEdge.API.Core.Context
Assembly: LemonEdge.API.dll
Syntax
public class BusyProgressReporter : IProgressReporter, IBusyReporter
Constructors
BusyProgressReporter(IBusyReporter)
Creates a BusyProgressReporter that simply passes all IBusyReporter interface calls to this class and ignores IProgressReporter calls
Declaration
public BusyProgressReporter(IBusyReporter busy)
Parameters
Type | Name | Description |
---|---|---|
IBusyReporter | busy | A class that implements IBusyReporter |
BusyProgressReporter(IBusyReporter, IProgressReporter)
Creates a BusyProgressReporter that simply passes all IProgressReporter interface calls and all IBusyReporter calls to their relevant classes
Declaration
public BusyProgressReporter(IBusyReporter busy, IProgressReporter progress)
Parameters
Type | Name | Description |
---|---|---|
IBusyReporter | busy | A class that implements IBusyReporter |
IProgressReporter | progress | A class that implements IProgressReporter |
BusyProgressReporter(IProgressReporter)
Creates a BusyProgressReporter that simply passes all IProgressReporter interface calls to this class and ignores IBusyReporter calls
Declaration
public BusyProgressReporter(IProgressReporter progress)
Parameters
Type | Name | Description |
---|---|---|
IProgressReporter | progress | A class that implements IProgressReporter |
Properties
BusyReporter
The class that implements IBusyReporter
Declaration
public IBusyReporter BusyReporter { get; }
Property Value
Type | Description |
---|---|
IBusyReporter |
IsBusy
Indicates if the system is still showing as busy. Will hold true until an equal amount of calls to StopBusy() have been made as were to DisplayBusy(string)
Declaration
public bool IsBusy { get; }
Property Value
Type | Description |
---|---|
bool |
ProgressReporter
The class that implements IProgressReporter
Declaration
public IProgressReporter ProgressReporter { get; }
Property Value
Type | Description |
---|---|
IProgressReporter |
Methods
ApplySplit(decimal, decimal?)
Splits this IProgressReporter up to into one that when taking a progress percent will only move to a specified amount for the overall progress.
See remarks for more info
Declaration
public void ApplySplit(decimal total, decimal? startFromProgress)
Parameters
Type | Name | Description |
---|---|---|
decimal | total | The total amount progressing to 100% now will amount to of the underlying progress percentage increment |
decimal? | startFromProgress | Indicates we should start from a specific progress percentage, or the current progress percentage of this progress reporter if null |
Remarks
For instance we may currently be at 25%, and now have a task that will take us a further 30% but is going to be handed to a process that wants to report its progress moving from 0-100%.
var currentProgress = 25m;
reporter.ReportProgress(currentProgress, "Processing...");
reporter.ApplySplit(30, currentProgress);
for (int i = 0; i <= 100; i++)
reporter.ReportProgress(i, "Processing other task...");
//reporter current progress is now 55%
reporter.ClearSplit();
reporter.ReportProgress(currentProgress + 31, "Continuing Processing...");
ClearSplit()
Clears any current split on this progress reporter and sets any progress back to being calculated with the actual percent provided
Declaration
public void ClearSplit()
CreateFromSplit(decimal, decimal?)
Creates a new BusyProgressReporter with the specified ApplySplit(decimal, decimal?) applied to it
Declaration
public BusyProgressReporter CreateFromSplit(decimal total, decimal? startFromProgress)
Parameters
Type | Name | Description |
---|---|---|
decimal | total | The total amount progressing to 100% now will amount to of the underlying progress percentage increment |
decimal? | startFromProgress | Indicates we should start from a specific progress percentage, or the current progress percentage of this progress reporter if null |
Returns
Type | Description |
---|---|
BusyProgressReporter | A new BusyProgressReporter with the specified ApplySplit(decimal, decimal?) applied to it |
DisplayBusy(string)
Displays the specified message to the user while the system is busy processing.
This is added to a stack of busy messages. The system will continue to display itself as busy until an equal amount of StopBusy() calls are made
Declaration
public void DisplayBusy(string msg)
Parameters
Type | Name | Description |
---|---|---|
string | msg | The message to be displayed as the system is busy processing |
FlushAllPendingMessages()
Writes all pending messages in the progress reporter
Declaration
public Task FlushAllPendingMessages()
Returns
Type | Description |
---|---|
Task | A task that indicates when the operation is complete |
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. Also sets the IBusyReporter to busy with this message too
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
. Also
sets the IBusyReporter to busy with this message too
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
. Also
sets the IBusyReporter to busy with this message too
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 |
StopBusy()
Stops the system from displaying the message associated with the last call to DisplayBusy(string)
The system will then show as no longer being busy, or still busy showing the last message provided to DisplayBusy(string) until an equal amount of calls to this method is made as was to DisplayBusy(string)
Declaration
public void StopBusy()