TMtxProgressDialog Class

Component→TMtxComponent→TMtxProgressDialog

type TMtxProgressDialog = class(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".
CancelbooleanAllows execution stop by user.
CounterIntegerCounts number of loops.
EditorActiveBooleanReturns True, if the component editor is displayed.
ReferenceTReferenceListStores a list of components that have to be notified, when this component is destroyed.
RuntimeTMtxProgressRuntimeHolds internal runtime object.
TerminatingExceptionstringReturns string different from nil, if an exception was raised during processing.

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.
Create
DefineLoopSet the range of loop with one procedure call.
DefineProgressBarControl external progress bar.
Destroy
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.
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.