Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,27 @@ void PlatformThread::createNewThread(decaf_thread_t* handle, threadMainMethod th
int priority, long long stackSize, long long* threadId) {

unsigned int osThreadId = 0;

*handle = (HANDLE)_beginthreadex(
NULL, (DWORD)0, threadMain, threadArg, 0, &osThreadId );

if (*handle == 0) {
throw RuntimeException(
__FILE__, __LINE__, "Failed to create new Thread." );
uintptr_t result = _beginthreadex(NULL, (DWORD)0, threadMain, threadArg, 0, &osThreadId);
char errorMessage[256];

*handle = nullptr;

if (((uintptr_t )-1L) == result)
{
sprintf_s(errorMessage, sizeof(errorMessage), "Failed to create new Thread. Result: -1. Error code: %d. DOS Error code: %d.", errno, _doserrno);

throw RuntimeException(__FILE__, __LINE__, errorMessage);
}


*handle = (decaf_thread_t)result;

if (nullptr == *handle)
{
sprintf_s(errorMessage, sizeof(errorMessage), "Failed to create new Thread. Result: NULL. Error code: %d. DOS Error code: %d.", errno, _doserrno);

throw RuntimeException(__FILE__, __LINE__, errorMessage);
}

*threadId = (long long)osThreadId;
}

Expand Down