Skip to content

scriptDone

ffredyk edited this page Jul 23, 2026 · 1 revision

scriptDone

Category

Concurrency

Arity

UnaryscriptDone <scriptHandle>.

scriptDone <scriptHandle>

Description

Returns true if the ScriptHandle has been resolved (the spawned code finished or was terminated). Returns false if the code is still running. Does not suspend — this is a non-blocking status check.

Equivalent to isNull _handle.

How It Works

Checks the internal IsResolved flag on the handle. O(1) query. No side effects.

Usage

Non-blocking check

_handle = spawn { sleep 5; doWork(); };

// Later, check without suspending:
if (scriptDone _handle) then {
    systemChat "Task complete";
} else {
    systemChat "Still working...";
};

Polling loop (not recommended — use await)

while { !scriptDone _handle } do {
    // do other work while waiting
    sleep 0.1;
};

Checking multiple handles

_allDone = true;
{ if (!scriptDone _x) then { _allDone = false } } forEach _handles;
if (_allDone) then {
    systemChat "All tasks complete";
};

Guard before getting result

if (scriptDone _handle) then {
    _result = await _handle;   // returns immediately since already done
};

vs await

// scriptDone: check without waiting
_done = scriptDone _handle;

// await: wait until done, get result
_result = await _handle;

Thread Safety

ReadOnly — pure query. Safe from any scheduler.

See Also

  • isNull — same behavior, SQF compat name
  • await — wait for handle and get result
  • terminate — force-resolve handle
  • spawn — create handle

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally