What happens to the value returned from the function passed to QueueUserWorkItem?
QueueUserWorkItem function schedules a function to be called from a thread pool thread. It’s one of the so-called legacy thread pool functions, a group of functions introduced in Windows 2000 in the first version of the system thread pool. It has since been superseded by the new thread pool functions like
CreateThreadpoolWork, but the old functions continue to work, for compatibility. (They are implemented as wrappers around the new thread pool functions.)
QueueUserWorkItem function takes a
LPTHREAD_ function pointer as the function to run on a thread pool thread. This is curious because the
LPTHREAD_ function returns a
DWORD. What does the system do with the
DWORD returned by a work item?
The return value is simply discarded.
It doesn’t matter what you return, as long as you return something. (And do make sure you return something. Don’t just fall off the end of the function and return uninitialized garbage, because that uninitialized garbage could be deadly.)