# scriptDone ## Category Concurrency ## Arity **Unary** — `scriptDone `. ``` scriptDone ``` ## 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 ```sqf _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) ```sqf while { !scriptDone _handle } do { // do other work while waiting sleep 0.1; }; ``` ### Checking multiple handles ```sqf _allDone = true; { if (!scriptDone _x) then { _allDone = false } } forEach _handles; if (_allDone) then { systemChat "All tasks complete"; }; ``` ### Guard before getting result ```sqf if (scriptDone _handle) then { _result = await _handle; // returns immediately since already done }; ``` ### vs await ```sqf // 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](isNull.md) — same behavior, SQF compat name - [await](await.md) — wait for handle and get result - [terminate](terminate.md) — force-resolve handle - [spawn](spawn.md) — create handle