-4

I am working on some legacy code which includes calls to WaitForMultipleObjects(). From school I remember the function WaitForMultipleObjectsEx() (which we only vaguely mentioned). I am wondering what, if at all, is the difference and is there a general rule as to when to use which. Googling the title of the question didn't lead to any conclusions.

Deanna
  • 23,876
  • 7
  • 71
  • 156
Digital Da
  • 891
  • 1
  • 10
  • 23
  • 1
    There's **tons** of ??? and ???Ex functions in Windows... same thing here, nothing really fancy going on. – user541686 Jul 05 '12 at 08:49
  • 6
    What do you not understand from [WaitForMultipleObjectsEx MSDN Link](http://msdn.microsoft.com/en-us/library/windows/desktop/ms687028%28v=vs.85%29.aspx) and [WaitForMultipleObjects MSDN Link](http://msdn.microsoft.com/en-us/library/windows/desktop/ms687025%28v=vs.85%29.aspx) there is an additional BOOL parameter to indicate if it is alertable, the MSDN article is pretty clear – EdChum Jul 05 '12 at 08:51
  • Generally, the `Ex` functions are newer versions, with an extended interface. Do you need the extra features offered? – Bo Persson Jul 05 '12 at 08:53
  • I saw this post a few days ago: http://stackoverflow.com/questions/11340811/whats-the-difference-between-waitformultipleobjects-and-waitformultipleobjectsehttp://stackoverflow.com/questions/331536/windows-threading-beginthread-vs-beginthreadex-vs-createthread-c and I was wondering if there is something to be learnt in the difference of WaitFor... Pretty new to Windows API and wasn't aware to the ??? and ???Ex issue. – Digital Da Jul 05 '12 at 09:00
  • The thing you can learn from having some functions in several versions (like "...Ex" or "...1") is that Windows has been around for a while, and every now and then Microsoft needed to add a new feature that didn't really fit into the existing parameter list. In many cases, you can use the new function and supply suitable values for the new parameters to get the behavior of the old function, but that's not generally necessary since most of the old functions are not deprecated (sometimes they are) – Christian Stieber Jul 05 '12 at 09:34

1 Answers1

4

As already stated, the routines with the addded "Ex" usually have some extended functionality of the original function. In this case there is an extra boolean parameter "bAlertable". The difference here is that this extra parameter, if set to true, allows you to wait on, not only objects in a signaled state and time-outs but also I/O completions and user-mode asynchronous procedure calls. This added feature lets you make your own completion routines for reads and writes. If you don't need the extra feature just call this function with the bAlertable parameter set to FALSE, or you can just use the older version without the parameter.

akagixxer
  • 1,767
  • 3
  • 21
  • 35