{"id":104746,"date":"2021-01-21T07:00:00","date_gmt":"2021-01-21T15:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=104746"},"modified":"2021-01-19T21:39:31","modified_gmt":"2021-01-20T05:39:31","slug":"20210121-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20210121-00\/?p=104746","title":{"rendered":"What happens to the value returned from the function passed to Queue&shy;User&shy;Work&shy;Item?"},"content":{"rendered":"<p>The <code>Queue\u00adUser\u00adWork\u00adItem<\/code> function schedules a function to be called from a thread pool thread. It&#8217;s one of the so-called <i>legacy thread pool functions<\/i>, 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 <code>Create\u00adThreadpool\u00adWork<\/code>, but the old functions continue to work, for compatibility. (They are implemented as wrappers around the new thread pool functions.)<\/p>\n<p>Curiously, the <code>Queue\u00adUser\u00adWork\u00adItem<\/code> function takes a <code>LPTHREAD_<wbr \/>START_<wbr \/>ROUTINE<\/code> function pointer as the function to run on a thread pool thread. This is curious because the <code>LPTHREAD_<wbr \/>START_<wbr \/>ROUTINE<\/code> function returns a <code>DWORD<\/code>. What does the system do with the <code>DWORD<\/code> returned by a work item?<\/p>\n<p>Nothing.<\/p>\n<p>The return value is simply discarded.<\/p>\n<p>It doesn&#8217;t matter what you return, as long as you return <i>something<\/i>. (And do make sure you return <i>something<\/i>. Don&#8217;t just fall off the end of the function and return uninitialized garbage, because <a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040119-00\/?p=41003\"> that uninitialized garbage could be deadly<\/a>.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nothing. Nothing at all.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-104746","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Nothing. Nothing at all.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=104746"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104746\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=104746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=104746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=104746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}