24.2.4 FlushBlocks() and FlushBlocksEx() Implementation

FlushBlocks() and FlushBlocksEx() are used to ensure that all pending writes have been completed on the mass storage device. This can be used as part of a check before removing some media from the system. Combinations of both read and write operations may be performed as part of this operation.

If a non-blocking request is made through FlushBlocksEx(), then start the request and if the request is expected to take some time to complete, set up a timer event to periodically check the completion status and return immediately. When the request is complete, signal the event passed into FlushBlocksEx() to inform the caller that the previous request has been completed.