RealThread Object

class RealThread extends Object

Runs callbacks on a real managed worker thread. This is distinct from the cooperative script pseudo-threads.

This class is exported by the KS module.

Call

Worker := RealThread.Call(Callback , Params*)

Starts Callback on a worker and returns its RealThread object.

ContinueWith

Continuation := Worker.ContinueWith(Callback , Params*)

Starts Callback on a new worker after this worker finishes and returns the continuation's RealThread object.

Post

Worker.Post(Callback , Params*)

Queues a callback on the worker and returns immediately.

Send

Result := Worker.Send(Callback , Params*)

Runs a callback synchronously on the worker and returns its result.

Wait

Result := Worker.Wait(Timeout)

Waits for the worker to complete and returns its result. Timeout is milliseconds; omit it to wait indefinitely.

Properties

Id

The managed ID of the backing worker thread.

IsAlive

True while the worker can accept work.

Remarks

State shared between real threads requires synchronization. Use LockRun or another appropriate design when callbacks mutate shared objects.