Skip to main content

csDestroying

csDestroying = 3

Example

function ComponentCanStartWork(const State: TComponentState): Boolean;
begin
Result := not (csDestroying in State);
end;

Usage

csDestroying marks a component whose destruction has started or is imminent, warning callers not to initiate new work through it.

Additional Technical Info

csDestroying is member ordinal 3 of the component-state element enumeration and a flag in TComponentState. The component framework sets it during destruction and propagates destruction notification through owned components.

Treat it as a warning to avoid starting callbacks, I/O or access through the component. It is not a lifetime guarantee: the object can be freed immediately after a check, and an already freed reference cannot safely be queried. The flag is therefore not a lock, reference count or substitute for producer-defined ownership.

Scripts cannot set the read-only state. Never free a host-owned component merely because this flag appears. The example is source-reviewed only; no component was destroyed.

External references

Created 2026-07-15