What happens to the value returned from the function passed to Queue­User­Work­Item?

Raymond Chen

The Queue­User­Work­Item 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 Create­Threadpool­Work, but the old functions continue to work, for compatibility. (They are implemented as wrappers around the new thread pool functions.)

Curiously, the Queue­User­Work­Item function takes a LPTHREAD_START_ROUTINE function pointer as the function to run on a thread pool thread. This is curious because the LPTHREAD_START_ROUTINE 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.)