Asynchronous vs. synchronous mode

Although the driver can be used in synchronous (FILE_ATTRIBUTE_NORMAL in CreateFile) or asynchronous (FILE_FLAG_OVERLAPPED) mode. It is not recommended to use the synchronous mode as it has an serious disadvantage. Every request to the driver (WriteFile, ReadFile, DeviceIoControl) must finish, before the next request can be processed. This means, if you have a ReadFile pending (waiting for data packets) you cannot deinit the driver or execute a WriteFile. Also cancelling the pending request via CancelIo is not possible!

This is the main reason, why you should (in most cases) use the asynchronous mode. The asynchronous mode causes little more programming overhead, but enables you, to take advantage of having several requests running at the same time.

The asynchronous mode can be split in 2 more modes:

  1. "Blocking"
    means the application wait for result by using function GetOverlappedResult with the parameter "bWait" set to TRUE.This mode should be used in a multithreading application.
    This mode is used for the example code fragments in this documentation.
  2. "Nonblocking"
    means GetOverlappedResult() returns immediately (parameter bWait set to FALSE). In this case you have to poll (call GetOverlappedResult again), if and when the operation is finished. This mode is useful with a single-threaded application, where some other work must be done meantime.

For a more detailed information please consult the manuals of your compiler manuals or the SDK from Microsoft (see MSDN Library).

Back to Programming Guide Contact Copyright and Disclaimer