Add support for foreground thread affinity