Suspending Threads Before Setting Affinity

A thread must be suspended before you can set its affinity.

General workflow for new threads:

  1. Create the thread in a suspended state using the CREATE_SUSPENDED flag (CreateThread)
  2. Set the thread's affinity mask (SetThreadAffinityMask)
  3. Resume the thread (ResumeThread)

General workflow for existing threads:

  1. Suspend the running thread (SuspendThread).
  2. Set the thread's affinity mask (SetThreadAffinityMask).
  3. Resume the thread (ResumeThread).

Related topics: