فئة System::Threading::Thread
محتويات
[
يخفي
]Thread class
Thread implementation. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.
class Thread : public System::Object
الطرق
| طريقة | الوصف |
|---|---|
| Abort() | يوقف الخيط. غير مُنفّذ. |
| get_CurrentCulture() | يحصل على ثقافة الخيط. |
| static get_CurrentThread() | يحصل على الكائن الذي يصف الخيط الحالي. |
| get_CurrentUICulture() | يحصل على ثقافة واجهة المستخدم المستخدمة من قبل الخيط. |
| get_IsAlive() | يتحقق مما إذا كان الخيط حياً. |
| get_IsBackground() | يتحقق مما إذا كان الخيط في الخلفية. |
| get_IsThreadPoolThread() | يتحقق مما إذا كان الخيط مملوكاً من قبل مجموعة الخيوط. |
| get_ManagedThreadId() const | يحصل على معرف الخيط. يمكن الحصول عليه من نظام التشغيل، ولكن إذا تجاوز معرف خيط نظام التشغيل حدود int، قد تتقاطع معرفات الخيوط. |
| get_Name() | يحصل على اسم الخيط. |
| get_ThreadState() | يحصل على حالة الخيط. |
| static GetCurrentThreadId() | يحصل على معرف الخيط الحالي. |
| GetHashCode() const override | |
| Interrupt() | يقاطع الخيط. غير مُنفّذ. |
| Join() | ينضم إلى الخيط المُدار. يُجري انتظاراً غير محدود إذا لزم الأمر. |
| Join(int) | ينضم إلى الخيط المُدار. يُجري انتظاراً محدوداً. |
| Join(TimeSpan) | ينضم إلى الخيط المُدار. يُجري انتظاراً محدوداً. |
| static MemoryBarrier() | يُزامن الوصول إلى الذاكرة. |
| operator=(const Thread&) | ينسخ بيانات TLS من خيط مختلف. |
| set_CurrentCulture(const SharedPtr<Globalization::CultureInfo>&) | يضبط ثقافة الخيط. |
| set_CurrentUICulture(const SharedPtr<Globalization::CultureInfo>&) | يضبط ثقافة واجهة المستخدم المستخدمة من قبل الخيط. |
| set_IsBackground(bool) | يضبط الخيط كخلفية أو أمامية. |
| set_Name(const System::String&) | يضبط اسم الخيط. |
| static Sleep(int) | يوقف الخيط الحالي لمدة زمنية محددة. |
| static Sleep(TimeSpan) | يوقف الخيط الحالي لمدة زمنية محددة. |
| static SpinWait(int) | ينتظر عددًا محددًا من تكرارات الحلقة. |
| Start() | يبدأ الخيط باستخدام كائن حجة فارغ. |
| Start(const System::SharedPtr<System::Object>&) | يبدأ الخيط. |
| Thread() | المُنشئ. |
| Thread(ThreadStart) | المُنشئ. |
| Thread(ParameterizedThreadStart) | المُنشئ. |
| Thread(Thread&) | منشئ النسخ. |
| static Yield() | يُنتج خيطًا. |
| virtual ~Thread() | المدمر. |
ملاحظات
#include "system/threading/thread.h"
#include "system/smart_ptr.h"
int main()
{
auto thread = System::MakeObject<System::Threading::Thread>([]()
{
std::cout << "Child thread ID: " << System::Threading::Thread::GetCurrentThreadId() << std::endl;
System::Threading::Thread::Sleep(200);
});
std::cout << "Main thread ID: " << System::Threading::Thread::GetCurrentThreadId() << std::endl;
thread->Start();
thread->Join();
return 0;
}
/*
This code example produces the following output:
Main thread ID: 2
Child thread ID: 1
*/
انظر أيضًا
- Class Object
- Namespace System::Threading
- Library Aspose.Font for C++