{"id":32533,"date":"2006-01-25T10:00:18","date_gmt":"2006-01-25T10:00:18","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/01\/25\/you-can-call-msgwaitformultipleobjects-with-zero-handles\/"},"modified":"2006-01-25T10:00:18","modified_gmt":"2006-01-25T10:00:18","slug":"you-can-call-msgwaitformultipleobjects-with-zero-handles","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20060125-18\/?p=32533","title":{"rendered":"You can call MsgWaitForMultipleObjects with zero handles"},"content":{"rendered":"<p>\nThere is no <code>WaitMessageTimeout<\/code> function,\nbut you can create your own with the assistance of\nthe <code>MsgWaitForMultipleObjects<\/code> function.\n<\/p>\n<pre>\nBOOL WaitMessageTimeout(DWORD dwTimeout)\n{\n return MsgWaitForMultipleObjects(\n    0, NULL, FALSE, dwTimeout, QS_ALLINPUT)\n      == WAIT_TIMEOUT;\n}\n<\/pre>\n<p>\nTo wait for a message with timeout, we use\nthe <code>MsgWaitForMultipleObjects<\/code>\nin a vacuous sense:\nYou pass it a list of objects you want to wait for,\nas well as a timeout and a set of queue states,\nasking that the function return when any of the\nobjects is signalled or when a message is ready.\nBy passing no objects, the only thing left to wait\nfor is an incoming message.\n<\/p>\n<p>\nNext time, we&#8217;ll see how this basic idea can be used\nto build a slightly more complex function.\n<\/p>\n<p>\n[1\/26: Fix call to MsgWaitForMultipleObjects; had it confused\nwith MsgWaitForMultipleObjectsEx.\nThat&#8217;s what happens when you write entries on an airplane.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is no WaitMessageTimeout function, but you can create your own with the assistance of the MsgWaitForMultipleObjects function. BOOL WaitMessageTimeout(DWORD dwTimeout) { return MsgWaitForMultipleObjects( 0, NULL, FALSE, dwTimeout, QS_ALLINPUT) == WAIT_TIMEOUT; } To wait for a message with timeout, we use the MsgWaitForMultipleObjects in a vacuous sense: You pass it a list of objects you [&hellip;]<\/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-32533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>There is no WaitMessageTimeout function, but you can create your own with the assistance of the MsgWaitForMultipleObjects function. BOOL WaitMessageTimeout(DWORD dwTimeout) { return MsgWaitForMultipleObjects( 0, NULL, FALSE, dwTimeout, QS_ALLINPUT) == WAIT_TIMEOUT; } To wait for a message with timeout, we use the MsgWaitForMultipleObjects in a vacuous sense: You pass it a list of objects you [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/32533","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=32533"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/32533\/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=32533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=32533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=32533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}