Visual Basic Concepts

Asynchronous Call-Backs and Events

When a client makes a method call, it’s blocked until the call returns. That is, the client can’t execute any code while it’s waiting. This is known as synchronous processing. By using asynchronous processing, you can free the client to do other things while it’s waiting.

In asynchronous processing, the method call that starts a task returns instantly, without supplying a result. The client goes about its business, while the component works on the task. When the task is complete, the component notifies the client that the result is ready.

Asynchronous processing is also useful when clients need to be notified of interesting occurrences — for example, changes in database values, or the arrival of messages. A client tells a component it wants to be notified when certain things happen, and the component sends notifications when those things occur.

Both of these scenarios depend on asynchronous notifications. The client application is minding its own business, when out of the blue comes a notification that an asynchronous request is complete, or that something of interest has occurred.

Visual Basic provides two mechanisms — events and call-back methods — for implementing asynchronous notifications, as discussed in the following topics.

For More Information   "Creating an ActiveX EXE Component" contains step-by-step procedures for implementing asynchronous notifications using both events and call-back methods.