ConvenienceThread class
Base class for a plain OS thread whose body is Run.
- Use
import ThinkMeta.ConcurrentTasks.Windows.ConvenienceThread;- Namespace
ThinkMeta::ConcurrentTasks::Windows
Syntax
class ConvenienceThreadRemarks
Derive, implement Run, call Create. Run executes on the new thread, which is not a task (call ConvertThreadToTask in Run to use the task primitives). The object must outlive the thread: wait for it (Wait) before destroying the object, because Run is called on it. The destructor closes the handle but does not wait.
See also
Constructors
ConvenienceThreadprotected
~ConvenienceThreadprotected
Closes the thread handle.
Syntax
virtual ~ConvenienceThread() noexcept = default;Remarks
Does not wait for the thread.
Methods
Create
Starts the thread, which calls Run.
Syntax
bool Create(size_t stackSize = 0) noexcept;Parameters
stackSizesize_t- Initial stack size in bytes;
0means the default stack size.Default:0
Return value
Type: bool
true if the thread was started; false on failure (GetLastError has the reason).
Remarks
Call once.
See also
IsValid
Returns whether the thread handle is open (created and not closed).
Syntax
bool IsValid() const noexcept;Return value
Type: bool
true if the handle is open; otherwise false.
Close
Closes the thread handle.
Syntax
bool Close() noexcept;Return value
Type: bool
true on success, also if no handle was open; false on failure (GetLastError has the reason).
Remarks
The thread keeps running; Wait is no longer possible afterwards.
Wait
Waits until the thread has exited.
Syntax
bool Wait(DWORD milliseconds) noexcept;Parameters
millisecondsDWORD- Timeout in milliseconds;
INFINITEwaits without one.
Return value
Type: bool
true if the thread has exited, false if the wait timed out or failed.
Remarks
Blocks the calling OS thread: called from a task it blocks the whole scheduler thread.
See also
Runprotected
The thread's body.
Syntax
virtual void Run() noexcept = 0;Remarks
Called once on the new thread; the thread ends when it returns.
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).