In ntmain, call set_main_thread() before running the loop.