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
Inheritance
Inherited Members
Namespace: LemonEdge.Entities.Processors
Assembly: 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 |
---|---|
System.Boolean |
ProgressReporter
The class that implements IProgressReporter
Declaration
public IProgressReporter ProgressReporter { get; }
Property Value
Type | Description |
---|---|
IProgressReporter |
Methods
ApplySplit(Decimal, Nullable<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 |
---|---|---|
System.Decimal | total | The total amount progressing to 100% now will amount to of the underlying progress percentage increment |
System.Nullable<System.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, Nullable<Decimal>)
Creates a new BusyProgressReporter with the specified ApplySplit(Decimal, Nullable<Decimal>) applied to it
Declaration
public BusyProgressReporter CreateFromSplit(decimal total, decimal? startFromProgress)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | total | The total amount progressing to 100% now will amount to of the underlying progress percentage increment |
System.Nullable<System.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, Nullable<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 |
---|---|---|
System.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 |
---|---|
System.Threading.Tasks.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 |
---|---|---|
System.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 |
---|---|---|
System.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 |
---|---|---|
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 |
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()