TMtxProgressDialog Class

Source: Controls/ProgressDlg.cs · Assembly: Dew.Math.Controls
ComponentTMtxComponentTMtxProgressDialog

public class TMtxProgressDialog : TMtxComponent

Manages and provides progress indicators of multi-threaded algorithms.

The TMtxProgressDialog component greatly simplifies the display of progress indicators and offers built-in support to cancel the execution of algorithms running in it's background thread. The progress can be indicated with events or by displaying its improvised progress dialog.

The design does not use the Synchronize procedure to update progress indicators and makes the most out of the available CPU power.

Usage example:

myProgress.DefineLoop(0, 1000-1); //how many times OnCompute should be called myProgress.OnCompute := MyCompute; //Mycompute will be called from a single background thread myProgress.OnProgressUpdate := MyProgressUpdate; //for progress indicators. Runs in main apps thread myProgress.Start;

When the processing finishes, the OnProgressUpdate will be called with TMtxProgressEvent.peCleanUp param from the main UI thread. The computation can be cancelled, by setting

myProgress.Cancel := True;

If the desire is to cancel and to block execution until all the processing has stopped call:

myProgress.Stop;

If the desire is to block execution and wait until all the processing has stopped call:

myProgress.WaitToFinish; // prefer OnProgressUpdate to detect the end (!)

The blocking calls however defeat the primary purpose of this component, which is to provide non-blocking interface to launch, track and detect the end of processing.

The component is targeted at user interaction with the UI and its one internal thread should not be used for massivally parallel computations.Use MtxVec.DoForLoop for such tasks. DoForLoop could/should/can be placed inside of MyCompute to do the actual mult-threaded computation.

Properties

NameTypeDescription
BlockAssignBooleanBlock streaming of specific properties when storing only a "template".
CancelBooleanIf true, cancel thread execution.
CounterInt32Cycle counter.
EditorActiveBooleanReturns True, if the component editor is displayed.
InfiniteLoopBooleanIf Dew.Math.Controls.TMtxProgressDialog.InternalLoop is true and InfiniteLoop is set to true, the thread will be calling OnCompute event until Dew.Math.Controls.TMtxProgressDialog.Cancel is changed to true.
InternalLoopBooleanIf set to true, the Dew.Math.Controls.TMtxProgressDialog.Compute event will be called Dew.Math.Controls.TMtxProgressDialog.Loops times, from Min to Max. If set to false, the OnCompute event will be called only once and the user can use any kind of processing within Dew.Math.Controls.TMtxProgressDialog.Compute event.
LoopsInt32Number of loops to execute if Dew.Math.Controls.TMtxProgressDialog.InternalLoop is true.
MaxInt32Defines the upper index for the loop.
MinInt32Defines the lower index for the loop.
PriorityThreadPriorityThe priority of the executing thread.
ReferenceTReferenceListStores a list of components that have to be notified, when this component is destroyed.
RuntimeTMtxProgressRuntimeDirect access to the underlying runtime. Exposed for advanced scenarios, but hidden from the designer to preserve the classic ProgressDialog surface.
ShowDialogBooleanIf true, the component will display it's default progress dialog.
TerminatingExceptionStringCycle counter.
ThreadBypassBooleanBypass using thread.
ThreadNameStringThread name.
UpdateIntervalInt32Defines the time interval in miliseconds between calls to OnProgressUpdate with peCycle parameter, while the background thread is executing.
WorkerActiveBooleanTrue while a background worker is active.

Methods

NameDescription
AllowStreamingReturns the negatated value of BlockAssign.
AssignAssign values of all published properties from Source.
AssignTemplateAssign values of "template-like" published properties from Source.
ctor (2)Constructor.
DefineLoopSet the range of loop with one method call.
DefineProgressBarSetup progress bar control.
EditorClassTo be overriden in descendanr classses.
LoadFromStreamLoad the component from Src stream.
LoadTemplateFromFileLoad a template from file.
LoadTemplateFromStreamLoad a template from stream.
ResetReset is called after loading the data from stream or file.
SaveTemplateToFileSave template to file.
SaveTemplateToStreamSave template to stream.
SaveToStreamSave the component to Dst stream.
StartStart execting the thread.
StopStop executing the thread.
TerminateAlias for Stop.
WaitToFinishBlock until the background job finishes.

Constants

NameTypeDescription
FormFormProgress dialog form.

Events

NameDescription
CleanUpCalled after the thread has completed from the main thread.
ComputeThe actual algorithm, that needs to be threaded or it's progress monitored, should be placed within this event.
ExceptionCalled if the worker raises an exception.
InitializeCalled as main thread is being initialized.
ProgressCalled as progress indicator is updated.
ProgressUpdateThe event is called before the thread starts executing with Dew.Math.TMtxProgressEvent.peInit parameter.