windows: replace `_beginthreadex()` with `CreateThread()`
Replace `_beginthreadex()` C runtime calls with native win32 API
`CreateThread()`. The latter was already used in `src/tool_doswin.c`
and in UWP and Windows CE builds before this patch. After this patch
all Windows flavors use it. To drop PP logic and simplify code.
While working on this it turned out that `src/tool_doswin.c` calls
`TerminateThread()`, which isn't recommended by the documentation,
except for "the most extreme cases". This patch makes no attempt
to change that code.
Ref:
9a2663322c330ff11275abafd612e9c99407a94a #17572
Ref: https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread
Also:
- use `WaitForSingleObjectEx()` on all desktop Windows.
Ref:
4be80d5109a340973dc6ce0221ec5c5761587df0
Ref: https://sourceforge.net/p/curl/feature-requests/82/
Ref: https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-waitforsingleobjectex
- tests: drop redundant casts.
- lib3207: fix to not rely on thread macros when building without thread
support.
Assisted-by: Jay Satiro
Assisted-by: Marcel Raad
Assisted-by: MichaĆ Petryka
Follow-up to
38029101e2d78ba125732b3bab6ec267b80a0e72 #11625
Closes #18451