INFO: Canceling Overlapped I/O

Last reviewed: April 10, 1997
Article ID: Q90368
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT versions 3.10, 3.50, 3.51, 4.0 - Microsoft Windows 95

SUMMARY

You can use the CancelIo() API function to cancel overlapped I/O. This function is available on Microsoft Windows NT 4.0. Previous versions of Windows NT and Windows 95 do not have CancelIo(), but there are alternative methods to cancel an asychronous I/O operation.

MORE INFORMATION

Windows NT 4.0 introduces a new API function to cancel overlapped I/O. Please see the Win32 SDK Function Reference for CancelIo() for more information.

Prior to Windows NT 4.0, and with Windows 95, there is no routine in the Win32 API to cancel an asynchronous request once it has been issued. When a thread does an overlapped I/O, the system starts up another thread to do the I/O and leaves your thread free to do other work. Once it is started, there is no way to stop it.

If it necessary to interrupt the I/O, you can either:

  • Split the writes into batches and check for interruptions. For example, you could break a 20 megabyte (MB) write into 20, 1 MB writes.

    -or-

  • Create another thread yourself to handle the I/O. By terminating the thread, you cancel the I/O. You should have a thread in the process that explicitly closes the handle to the device.

    -or-

  • Close the handle to the device with the pending I/O. The close has the net effect of canceling the I/O.


Keywords : BseFileio kbprg kbprg
Version : 3.1 3.5 3.51 4.0
Platform : NT WINDOWS
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.