Overview of Asynchronous Processing

Asynchronous processing enables methods to return immediately without blocking on the calling thread. Consumers request asynchronous processing when initializing a data source, or when opening or populating a rowset. The consumer must explicitly request asynchronous processing. Otherwise, the provider can perform asynchronous operations in the background, but must behave synchronously, blocking if necessary, until the underlying asynchronous operation completes.

Data Source Initialization properties are used when consumers initialize a data source asynchronously. Consumers wishing to asynchronously open a rowset use the Command Execution and Rowset Generation properties. Consumers wishing to asynchronously populate a rowset use properties of Rowset Population.

For more information on Go to
Calling thread "Provider Threading Models" in Chapter 14, "Programming Considerations"
Consumers "Consumers and Providers" in Chapter 1, "Overview of OLE DB"
Data source "Data Source Objects" in Chapter 2, "Enumerators, Data Source Objects, and Sessions"
Rowset Chapter 4, "Rowsets"
Asynchronously initialize a data source "Asynchronous Data Source Initialization" in this chapter
Asynchronously open a rowset "Asynchronous Command Execution and Rowset Generation" in this chapter
Asynchronously populate a rowset "Asynchronous Rowset Population" in this chapter

Consumers can poll for the status of an asynchronous operation by calling IDBAsynchStatus::GetStatus on the object being asynchronously processed, or can register for progress notifications by passing the consumer's IDBAsynchNotify interface to the connection point of the object being asynchronously processed.

Asynchronous processing can occur in phases. If the object is asynchronously initialized, the initialization phase occurs first. While the object is in the initialization phase it is in an uninitialized state. Attempting to call other interfaces may fail, and attempting to call QueryInterface for interfaces other than IConnectionPointContainer may return E_NOINTERFACE.

Once all asynchronous processing has completed for an operation, the provider calls IDBAsynchNotify::OnProgress with ulAsynchPhase set to DBASYNCHPHASE_COMPLETE for that operation, followed by IDBAsynchNotify::OnStop to notify listeners that asynchronous processing has completed. Any calls to IDBAsynchStatus::GetStatus for that operation return an HRESULT indicating the outcome of the operation, with ulAsynchPhase set to DBASYNCHPHASE_COMPLETE, pulProgress equal to pulProgressMax, and ppwszStatusString set to a provider-specific value indicating completion, or NULL.