DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
Thread.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "Common.h"
7#include "System/Object.h"
8#include "System/String.h"
9#include "System/Action.h"
10#include "System/SmartPointer.h"
11
12namespace DotNetDupe {
13 namespace System {
14 namespace Threading {
15
18
28 class Thread : public Object {
29 public:
33
37
38 DOTNETDUPE_API ~Thread() override;
39
41 DOTNETDUPE_API void Start();
42
45 DOTNETDUPE_API void Start(Object* parameter);
46
48 DOTNETDUPE_API void Join();
49
54 DOTNETDUPE_API bool Join(int millisecondsTimeout);
55
58 DOTNETDUPE_API static void Sleep(int millisecondsTimeout);
59
62 DOTNETDUPE_API bool IsAlive() const;
63
67
70 DOTNETDUPE_API void SetName(const String& name);
71
75
79
80 private:
81 Thread(); // For internal use (main thread wrapper)
82 static SmartPointer<Thread> CreateCurrentThreadWrapper();
83
84 struct Impl;
85 Impl* m_pImpl;
86
87 static thread_local Thread* _currentThread;
88
89 void ThreadMain(Object* parameter);
90 };
91 }
92 }
93}
Encapsulates a delegate method that has parameters and returns void.
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Encapsulates a method that has parameters and does not return a value.
Definition Action.h:46
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
String GetName() const
Gets the friendly name of the thread.
Definition Thread.cpp:129
static int GetCurrentThreadId()
Returns an integer identifier for the current managed thread.
Definition Thread.cpp:148
Thread(ThreadStart start)
Initializes a new instance of the Thread class with a parameterless start delegate.
Definition Thread.cpp:38
void Join()
Blocks the calling thread until the thread represented by this instance terminates.
Definition Thread.cpp:92
void Start()
Causes the operating system to change the state of the current instance to Running.
Definition Thread.cpp:78
static void Sleep(int millisecondsTimeout)
Suspends the current thread for the specified number of milliseconds.
Definition Thread.cpp:120
bool IsAlive() const
Gets a value indicating the execution status of the current thread.
Definition Thread.cpp:125
static Thread * GetCurrentThread()
Gets the currently running thread.
Definition Thread.cpp:137
void SetName(const String &name)
Sets the friendly name of the thread.
Definition Thread.cpp:133
Action< Object * > ParameterizedThreadStart
Definition Thread.h:17