Suspending Threads Before Setting Affinity
A thread must be suspended before you can set its affinity.
General workflow for new threads:
- Create the thread in a suspended state using the CREATE_SUSPENDED flag (CreateThread)
- Set the thread's affinity mask (SetThreadAffinityMask)
- Resume the thread (ResumeThread)
General workflow for existing threads:
- Suspend the running thread (SuspendThread).
- Set the thread's affinity mask (SetThreadAffinityMask).
- Resume the thread (ResumeThread).