ConvenienceThread class
Base class for a plain OS thread whose body is Run.
- Use
import ThinkMeta.ConcurrentTasks.Windows.ConvenienceThread;- Namespace
ThinkMeta::ConcurrentTasks::Windows- Platforms
- 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
ErrorCode Create(std::size_t stackSize = 0) noexcept;Parameters
stackSizestd::size_t- Initial stack size in bytes;
0means the default stack size.Default:0
Return value
Type: ErrorCode
Error::Success if the thread was started; otherwise the Win32 error.
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
ErrorCode Close() noexcept;Return value
Type: ErrorCode
Error::Success, also if no handle was open; otherwise the Win32 error.
Remarks
The thread keeps running; Wait is no longer possible afterwards.
Wait
Waits until the thread has exited.
Syntax
ErrorCode Wait(DWORD milliseconds) noexcept;Parameters
millisecondsDWORD- Timeout in milliseconds;
INFINITEwaits without one.
Return value
Type: ErrorCode
Error::Success if the thread has exited, Error::WaitTimedOut if the wait timed out, otherwise the Win32 error of the wait.
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 @ c7663c4 (2026-11-19).