TMtxProgressDialog Class

Header: Dew.Math.Controls.VCL/MtxDialogs.h · C++Builder only
tObjectTMtxComponentTMtxProgressDialog

class TMtxProgressDialog : public 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.

Constructors

NameDescription
TMtxProgressDialog

Destructors

NameDescription
~TMtxProgressDialog

Properties

NameTypeDescription
BlockAssignboolBlock streaming of specific properties when storing only a "template".
CancelboolAllows execution stop by user.
CounterintCounts number of loops.
DialogCaptionSystem::UnicodeStringCustom caption for the built-in progress dialog form.
EditorActiveboolReturns True, if the component editor is displayed.
InfiniteLoopboolCall TMtxProgressDialog::OnCompute in infinite loop.
InternalLoopboolNumber of TMtxProgressDialog::OnCompute calls.
LoopsintNumber of loops to execute if TMtxProgressDialog::InternalLoop property is set to True.
MaxintSets the upper index of "for loop".
MinintDeines the lower index of the "for loop".
NameDewString
OnBeforeDestroy::Dew::tNotifyEventEvent executed just before the object will be destroyed.
OnCleanUp::Dew::tNotifyEventEvent used to perform clean up for the thread.
OnComputeTComputeEventPlace the actual threading algorithm in this event.
OnExceptionTExceptionEventTriggered when an exception has occured inside the Thread and the thread is about to exit.
OnInitialize::Dew::tNotifyEventEvent used to perform initialization for the thread.
OnProgress::Dew::tNotifyEventEvent used for progress indicators.
OnProgressUpdateTProgressUpdateEventCalled before the thread start executing.
ReferenceTReferenceList*Stores a list of components that have to be notified, when this component is destroyed.
RuntimeTMtxProgressRuntime*Holds internal runtime object.
ShowDialogboolIf True, the component will display it's default progress dialog.
TerminatingExceptionSystem::UnicodeStringReturns string different from nil, if an exception was raised during processing.
ThreadBypassboolBypass thread.
ThreadNameSystem::UnicodeStringAllows the user to specify the name of the thread.
ThreadPriority::Dew::tThreadPriorityThread priority.
UpdateIntervalintDefines the time interval.

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.
Bridge_CleanUp
Bridge_Compute
Bridge_Exception
Bridge_Initialize
Bridge_ProgressTick
Bridge_ProgressUpdate
CancelClick
CreateProgressUI
DefineLoopSet the range of loop with one procedure call.
DefineProgressBarControl external progress bar.
DoThreadCleanUp
DoThreadInit
EditorClassTo be overriden in descendanr classses.
GetDialogCaption
GetOnBeforeDestroy
GetRuntime
GetShowDialog
GetTerminatingException
LoadFromStreamLoad the component from Src stream.
LoadTemplateFromFileLoad a template from file.
LoadTemplateFromStreamLoad a template from stream.
ProgressTick
ReferenceRemoved
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.
StartCall Start to start the execution of the thread.
StopCall Stop to request the loop to stop executing.
TerminateSignals the thread that it should terminate.
WaitToFinishReturns when the thread has finished.

Fields

NameTypeDescription
AFormTForm *Points to the progress dialog form, showing while thread is running, if ShowDialog property is True.
CancelButtonTButton *
PanelTPanel *
ProgressBarTProgressBar *
Tagintptr_t
WndListvoid *