TX Sheet Control

Lifetime and Concurrency

Topic

Each mutable document has an owner. Browser controls own their mounted UI, and backend controls own processing state. Handles identify objects inside one document generation and are invalid after a relevant deletion or replacement.

From ownership follow the rules for creating and disposing controls, for sharing them between jobs, for parallel requests and for grouping changes.

Own an Editor in the Browser

Create one editor per host. Then:

  1. Await ready, then operate through its workbook.
  2. When you remove the editor, remove your listeners and call destroy().

Angular performs its component cleanup automatically.

Important

Handles After Loading. Do not keep using handles from a document that has been replaced by load.

Run Backend Jobs

Each platform has its own way to dispose a backend control:

  • In .NET, use await using for controls, which releases them through DisposeAsync.
  • In Node.js, use try/finally plus destroy().

Await all work before disposal. Unrelated jobs must not share mutable edits, and a reused control should reload a clean input or template for each unrelated request.

Sessions

Sessions, which CreateSession creates in .NET, may share capacity with their owner. A session is not automatically a separate parallel worker. For throughput tests, distinguish a pool of independent controls from many requests serialized through shared processing capacity.

Bound Concurrency

Limit parallel requests with a queue or semaphore, or with a worker pool. Include initialization, file size, formula count, PDF pages, font use and memory in capacity planning.

Increasing concurrency can improve throughput while it increases latency and memory. Measure both.

Group Changes in Batches

  • In the browser, synchronous batches with batch group related changes.
  • In .NET, collect batch commands synchronously through the typed batch API: BatchAsync with a WorkbookBatch.

Fetch remote data before collecting mutations. Do not use asynchronous callbacks where the API requires synchronous collection.

Recover From Errors

Errors should leave a clearly defined document or result. If a request fails, discard or reload its state before reusing an owner for unrelated data.

Next Steps