diff --git a/BeefLibs/corlib/src/Threading/Thread.bf b/BeefLibs/corlib/src/Threading/Thread.bf index 8198c23e..b83b2cdd 100644 --- a/BeefLibs/corlib/src/Threading/Thread.bf +++ b/BeefLibs/corlib/src/Threading/Thread.bf @@ -11,7 +11,7 @@ namespace System.Threading public sealed class Thread { private int mInternalThread; - private int32 mPriority; + private ThreadPriority mPriority = .Normal; public int32 mMaxStackSize; private String mName ~ delete _; private Delegate mDelegate; @@ -67,6 +67,8 @@ namespace System.Threading if (thread.mName != null) thread.InformThreadNameChange(thread.mName); + if (thread.mPriority != .Normal) + thread.SetPriorityNative((.)thread.mPriority); int32 stackStart = 0; thread.SetStackStart((void*)&stackStart); @@ -219,8 +221,18 @@ namespace System.Threading public ThreadPriority Priority { - get { return (ThreadPriority)GetPriorityNative(); } - set { SetPriorityNative((int32)value); } + get + { + if (mInternalThread != 0) + return (ThreadPriority)GetPriorityNative(); + return mPriority; + } + set + { + mPriority = value; + if (mInternalThread != 0) + SetPriorityNative((int32)value); + } } [CallingConvention(.Cdecl)] private extern int32 GetPriorityNative(); diff --git a/BeefRT/rt/Thread.cpp b/BeefRT/rt/Thread.cpp index 5cf5dce8..655e71f4 100644 --- a/BeefRT/rt/Thread.cpp +++ b/BeefRT/rt/Thread.cpp @@ -53,12 +53,12 @@ void Thread::SetJoinOnDelete(bool joinOnDelete) int Thread::GetPriorityNative() { - return (int)BfpThread_GetPriority(GetInternalThread()->mThreadHandle, NULL); + return (int)BfpThread_GetPriority(GetInternalThread()->mThreadHandle, NULL) + 2; } void Thread::SetPriorityNative(int priority) { - return BfpThread_SetPriority(GetInternalThread()->mThreadHandle, (BfpThreadPriority)priority, NULL); + return BfpThread_SetPriority(GetInternalThread()->mThreadHandle, (BfpThreadPriority)(priority - 2), NULL); } bool Thread::GetIsAlive()