PRB: OLE Server Terminate Not Fired If Client Uses 'End'Last reviewed: October 30, 1995Article ID: Q129885 |
The information in this article applies to:
SYMPTOMSAn OLE Server with loaded forms does not unload when the client program terminates by using the End statement, even if the OLE server is programmed to unload its forms in the Terminate event.
CAUSEWhen you use End to shut down an object application, the Terminate events of objects are NOT executed. (This is analogous to forms -- if you use End, the QueryUnload, Unload, and Terminate events of forms are NOT executed.)
RESOLUTIONThis behavior occurs under Microsoft Windows 95, Microsoft Windows version 3.X, and Microsoft Windows for Workgroups version 3.11. It does not occur under Microsoft Windows NT. Good programming uses the Terminate event of a class module to clean up and release dependent object references. This is true for client applications that create OLE objects as well. The Terminate, QueryUnload, or Unload events gracefully close down any objects or forms that were created or loaded during the session. The End statement is convenient, but it does NOT go through the complete sequence of cleaning up after your application. You should use it cautiously and sparingly when developing applications. A Visual Basic client can destroy the last instance of an OLE Server it creates by:
STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
Example Resolution for Failure to Fire TerminateAdd the following statement before the End statement in step 6:
Set X = NothingThis explicitly unloads the OLE server, which fires the correct Terminate event. While the End statement is still not optimal, it will no longer cause problems with this OLE server.
|
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |