Next Previous Up Top Contents Index

4.6 Building an Automation server application

4.6.9 Cleaning up with TERMINATE

Besides the dispatch methods, your class will also probably need to provide a method for the terminate function. This function is called when the last client holding a reference to the dispinterface calls Release on it. You can supply a method on terminate to clean up data structures or to terminate the server application.

Note that terminate is not the same as finalize in the Functional-Extensions library's Finalization module. A finalize method may not be called immediately. Think of the terminate function as corresponding to a C++ destructor.

For example:

define method terminate (this :: <my-dispatch-object>) => ()
  next-method(); // don't forget this!
  // post ourselves a close message to end the program:
  PostMessage(this.my-window-handle, 
              $WM-SYSCOMMAND, 
              $SC-CLOSE, 0);
  values()
end method terminate ;


OLE, COM, ActiveX and DBMS Reference - 31 MAR 2000

Next Previous Up Top Contents Index