My guess is that the problem has to do with the Infinite loop. You need the thread to be capable of ending and returning to DllMain.
The DllMain function also does not wait for the thread to finish, often called "joining". You may be exiting the Dll before the thread can run fully, which probably is not the desired behavior.
See this example: https://learn.microsoft.com/en-us/windows/win32/procthread/creating-threads
Note that the threadArray is collecting the thread handles returned by createThread. They use that array of thread handles and a call to WaitForMultipleObjects() function for them all to finish, that is a blocking function that joins all the threads before continuing.
I find the C++ threads library easier to work with than the Windows API equivalent
Personally I prefer WIN32 threads - probably because I've used them since Win32 first appeared, our code is heavily threaded, we're Windows only and there's no ROI for us on changing to C++ threads which would involve some substantial across-the-board code changes.
However, for new systems I'd always recommend standard C++ over 3rd party libs (even though C++ threading in the case of Windows will be implemented using WIN32 APIs).
PS. When creating a thread using WIN32, always use _beginthreadEx() and NOT CreateThread(). CreateThread() may seem to work but has limitations (around CRT) which could well bite hard at some point.