MDAC 2.5 SDK - Technical Articles


 

Event Handling for Asynchronous Operations

Generally, in an asynchronous operation, a notification to the application signals that the operation is about to be asynchronously started. Later the application is notified that the operation is completed. In other words, a notification, or event, is a signal to the application that something has happened, and therefore developers must write event handlers to process the event. In ADO, the names given to the events follow a pattern: Events that happen before an operation are named "Willxxx," and events that happen after are named "xxxComplete."

All notifications are exposed on the Connection and Recordset objects. The Connection object notifications deal with connecting to the data store, executing commands, and processing transactions. The Recordset notifications are related to fetching of result sets, scrolling, changing, and updating.

ADO exposes a list of events that can be used to control all aspects of the connection, query, and row-access process. This provides finer control over all aspects of the data access operation and eliminates the need to poll while waiting for completion of asynchronous operations. In addition, this enables debugging by using the Visual Studio Enterprise Debugger.