I've got a set of tasks that I slaved to the NT threadpool using QueueUserWorkItem
. I need to make some calls to COM from these separate threads to access data inside WMI. I'm unsure, however, how the correct calls to CoInitializeEx
need to be made.
Basically, the CoInitializeEx
docs say that the call should be made once per thread. But I don't own these threads—NT does. I don't know when they get created or destroyed, or anything of that nature. Do I basically call ::CoInitializeEx()
(with COINIT_MULTITHREADED
) at the beginning of the thread routine, and then ::CoUninitialize()
at the end of my thread routine?