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
| Name | Type | Description |
|---|---|---|
| BlockAssign | Boolean | Block streaming of specific properties when storing only a "template". |
| Cancel | boolean | Allows execution stop by user. |
| Counter | Integer | Counts number of loops. |
| EditorActive | Boolean | Returns True, if the component editor is displayed. |
| Reference | TReferenceList | Stores a list of components that have to be notified, when this component is destroyed. |
| Runtime | TMtxProgressRuntime | Holds internal runtime object. |
| TerminatingException | string | Returns string different from nil, if an exception was raised during processing. |
Methods
| Name | Description |
|---|---|
| AllowStreaming | Returns the negatated value of BlockAssign. |
| Assign | Assign values of all published properties from Source. |
| AssignTemplate | Assign values of "template-like" published properties from Source. |
| Create | |
| DefineLoop | Set the range of loop with one procedure call. |
| DefineProgressBar | Control external progress bar. |
| Destroy | |
| EditorClass | To be overriden in descendanr classses. |
| LoadFromStream | Load the component from Src stream. |
| LoadTemplateFromFile | Load a template from file. |
| LoadTemplateFromStream | Load a template from stream. |
| Reset | Reset is called after loading the data from stream or file. |
| SaveTemplateToFile | Save template to file. |
| SaveTemplateToStream | Save template to stream. |
| SaveToStream | Save the component to Dst stream. |
| Start | Call Start to start the execution of the thread. |
| Stop | Call Stop to request the loop to stop executing. |
| Terminate | Signals the thread that it should terminate. |
| WaitToFinish | Returns when the thread has finished. |