Table of Contents

TTMSMCPTask Class

Server-side record of a long-running operation that a client can poll for progress, fetch a result from, and ask to have cancelled.

API unit family: TMS.MCP.Tasks Inherits from: TPersistent

Syntax

TTMSMCPTask = class(TPersistent)

Remarks

Tasks are created and looked up through TTMSMCPTaskRegistry rather than directly. A task belongs to the transport session that created it: a client only sees, polls and cancels the tasks of its own session, and an identifier belonging to another session is answered as if it did not exist. A task disappears on its own once its lifetime has elapsed. Tasks require the 2025-11-25 protocol version to have been negotiated.

Properties

Name Description
CreatedAt Moment the task was created. Read-only, and the point the lifetime is measured from.
Error Description of why the operation failed.
LastUpdatedAt Moment the state, status message, result or error was last changed. Read-only.
Method Name of the operation this task was started for. Assigned at creation and read-only afterwards.
PollInterval Interval in milliseconds the client is advised to wait between two status requests.
SessionId Identifier of the transport session that owns the task. Read-only, and empty for transports that have no sessions.
Status Current lifecycle state of the task. Starts out as tsWorking.
StatusMessage Short text describing what the operation is currently doing, shown to the user next to the state.
TTL Lifetime of the task in milliseconds, counted from TTMSMCPTask.CreatedAt.
TaskId Identifier the client uses to poll, cancel and fetch the result of this task. Assigned at creation and read-only afterwards.
TaskResult Value produced by the operation, handed to the client when it asks for the result.

Methods

Name Description
SignalTerminal Releases every caller that is waiting for this task to finish.
ToJSON Builds the status representation of the task that is sent to the client.
WaitForTerminal Blocks the calling thread until the task reaches a final state or the timeout elapses.

Used by