Wednesday, February 23, 2011

How to mark the specific I/O operations as cancelled.

Tip -  CancelSynchronousIo ()

Details - This function marks pending synchronous I/O operations that are issued by the specified thread as canceled.

BOOL WINAPI CancelSynchronousIo(
  __in  HANDLE hThread

hThread [in]
    A handle to the thread.
Ø  If the function succeeds, the return value is nonzero.
Ø  If the function fails, the return value is 0 (zero).
Ø  If this function cannot find a request to cancel, the return value is 0.
Ø  The caller must have the THREAD_TERMINATE access right.
Ø  If there are any pending I/O operations in progress for the specified thread, the CancelSynchronousIo function marks them for cancellation. Most types of operations can be canceled immediately; other operations can continue toward completion before they are actually canceled and the caller is notified. The CancelSynchronousIo function does not wait for all canceled operations to complete.

The operation being canceled is completed with one of three statuses; you must check the completion status to determine the completion state. The three statuses are:

    * The operation completed normally. This can occur even if the operation was canceled, because the cancel request might not have been submitted in time to cancel the operation.
    * The operation was canceled.
    * The operation failed with another error.

Posted By : Praveen V

No comments:

Post a Comment