TMtxProgressRuntime Class

type TMtxProgressRuntime = class(TPersistent);

Runtime for background execution and progress reporting.

UI-free runtime designed as TPersistent so a host component (WinForms/VCL wrapper) can expose it as a streamable sub-object. Provides timer-driven progress cycles and cooperative cancellation. The counter is maintained by the worker when threaded, and by the runtime when executing synchronously with TMtxProgressRuntime.ThreadBypass.

Constructors

NameDescription
CreateCreate a new runtime with default settings.

Properties

NameTypeDescription
CancelBooleanCooperative cancellation flag.
CounterIntegerLoop counter.
InfiniteLoopBooleanIf true and TMtxProgressRuntime.InternalLoop is true, repeats until TMtxProgressRuntime.Cancel becomes true.
InternalLoopBooleanIf false, TMtxProgressRuntime.OnCompute is called only once.
LoopsIntegerNumber of loops to execute when TMtxProgressRuntime.InternalLoop is true.
MaxIntegerUpper index for loop.
MinIntegerLower index for loop.
OnCleanUpTNotifyEventCalled after the job completes or is cancelled (on peCleanUp).
OnComputeTComputeEventThe user job to execute (runs on the worker thread).
OnExceptionTExceptionEventCalled if the worker raises an exception.
OnInitializeTNotifyEventCalled before execution starts (on TMtxProgressEvent.peInit).
OnProgressTNotifyEventCalled on each TMtxProgressEvent.peCycle tick.
OnProgressUpdateTProgressUpdateEventLifecycle event: TMtxProgressEvent.peInit, TMtxProgressEvent.peCycle, TMtxProgressEvent.peCleanUp.
PriorityThreadPriorityExecuting thread priority.
ThreadBypassBooleanBypass the background thread and execute synchronously (useful for testing).
ThreadNamestringWorker thread name (useful for debugging and diagnostics).
UpdateIntervalIntegerTime interval (ms) between TMtxProgressEvent.peCycle notifications.
WorkerActiveBooleanTrue while a background worker is active.

Methods

NameDescription
DefineLoopSet loop bounds in a single call.
FreeDestroy the runtime and stop any running worker.
StartStart execution.
StopRequest cooperative cancellation and wait for the worker to exit.
TerminateSets cancel to True.
WaitToFinishBlock until the background job finishes.