The declaration of ThreadId shows it to be a size_t, not a uint. A size_t on Win64 is a ulong, not a uint. So something is a bit fishy.