Sending I/O Requests Asynchronously
Before you can send an I/O request asynchronously to an I/O target, you must format the request. The following table lists the I/O target object methods that your driver can call to format I/O requests.
Method | Purpose |
---|---|
Formats a read request |
|
Formats a write request |
|
Formats a device control request |
|
Formats an internal device control request |
|
Formats a non-standard internal device control request |
To send an I/O request asynchronously, your driver must:
Format the request.
Use one of the methods that are listed in the previous table to format your requests. For detailed information about how to use these methods, see the methods' reference pages.
Register a CompletionRoutine callback function.
If you send requests asynchronously, you typically want the framework to notify your driver when another driver completes each request. Your driver should define a CompletionRoutine callback function and register it by calling WdfRequestSetCompletionRoutine. For more information, see Completing I/O Requests.
Send the request.
After your driver formats the request and registers a CompletionRoutine callback function, your driver must call WdfRequestSend. This method enables you to send requests either synchronously or asynchronously, depending on the flags set in the RequestOptions parameter. For a simpler way to send I/O requests synchronously, see Sending I/O Requests Synchronously. For information about how to get the completion status for an asynchronous request or for any request that is sent by calling WdfRequestSend, see Completing I/O Requests.
A driver that calls WdfRequestSend to send an I/O request can attempt to cancel the request later. For more information, see Canceling I/O Requests.
Some drivers might send a single I/O request to multiple devices, and thus to multiple I/O targets, by calling WdfRequestSend more than once for each request. These drivers must call WdfRequestChangeTarget before each call to WdfRequestSend after the first one to verify that the request can be sent to the next I/O target.