The information in this article applies to:
SUMMARYUnder OLE version 1.0, the OLE client and OLE server libraries communicate using dynamic data exchange (DDE) messages. Although this behavior will probably change in the future, the current behavior impacts the application. This article describes the effects of the asynchronous DDE protocol on an OLE application. MORE INFORMATION
Many OLE function calls, in both the OLE client and OLE server
libraries, return the value OLE_WAIT_FOR_RELEASE to signal that the
function initiated an asynchronous operation on a specific object,
document, or server. While an asynchronous operation is in process, an
application must not call any other OLE functions that affect the same
item because only one asynchronous operation per item is supported.
Therefore, when making a sequence of calls that relate to a single
item, the application must wait for each operation to complete before
calling the next. Waiting for All Objects in an OLE Client ApplicationSome operations, such as closing a file, in an OLE client application affect all objects in a document at the same time; waiting for each object individually is slow. Instead of waiting for each object in turn, an application can wait for all objects together. Note, however, that when this technique is used it is more difficult for the application to articulate errors for individual objects once the application leaves its message loop. However, for operations such as document close, the individual errors may not make any difference to the application.To wait for all objects at once, maintain a special counter to count how many objects are released and how many objects are waiting. The counter is affected by the following four sets of events:
The OLE_BUSY Return CodeIf the OLE server related to an object is involved in a modal operation or an incomplete asynchronous operation, an OLE function call will return the value OLE_BUSY to indicate that the operation cannot be executed. The application can either wait for the object to be released or terminate the operation. Whenever a function returns an OLE_BUSY value, the OLE client application's CallBack method receives an OLE_QUERY_RETRY_BUSY notification. The value returned from CallBack indicates whether or not to continue the operation in response to the notification. When the application receives this notification, it may be wise to inform the user and to provide an option to wait or to cancel.Debugging Asynchronous OperationsThe process of debugging an application that performs multiple operations on multiple objects can be quite involved. One method to address this complexity is to write the application in two phases. In the first phase of development, the application blocks operations on all OLE objects when any OLE function returns OLE_WAIT_FOR_RELEASE. Although waiting for each object in turn will probably cause the application to run more slowly, the application is much easier to debug. Waiting for each object effectively converts OLE into a synchronous protocol.Once the application has been debugged successfully at phase one, in phase two, extend the program to operate on several objects asynchronously. Extending the application in this manner will most likely improve its performance. Additional query words: 3.10 1.00
Keywords : |
Last Reviewed: October 26, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |