This is pretty straight forward, WaitForSingleObject () blocks the thread. It consumes a megabyte of virtual memory and does nothing useful with it while it is locked. He will not wake up and begin to do useful things until the handle is signaled.
RegisterWaitForSingleObject () does not block the stream. A thread can continue to do useful work. When the handle is signaled, Windows captures the thread pool thread to run the code that you specified as the callback. The same code that you programmed after calling WFSO. There is still a thread associated with getting this callback to start, the wait thread, but it can handle many RWFSO requests.
Thus, the big advantage is that your program can use far fewer threads when processing many service requests. The disadvantage is that the completion code may take a little longer. And itβs harder to program correctly, as this code runs on a different thread. Also note that you do not need RWFSO if you are already using overlapping I / O.
source share