Method: Destructor Done()

Every class and class variant definition may implement its own destructor. Destructors are specialized methods, which are invoked automatically during the disposal of unused objects to complement and finalize their de-initialization. In Embedded Wizard, destructors are usual methods named explicitly with the identifier Done and declared without any return value and any parameters:

Declaration of a destructor method within the Code Editor window.

Unlike an ordinary method, destructors are invoked by the system's own Garbage Collector only. Calling the Done() method directly from another method is not possible. Moreover, in derived classes when the destructor method is overridden, the system ensures automatically, that starting with the most recently derived class every destructor implementation of every ancestor class is being called. The usage of the pseudo method super() is not necessary and even not possible.

Add new Done() method

If there is no Done method inherited from an ancestor class, you have to add a new method explicitly:

First add a new method to your class.

Rename the method as Done.

Open the method for editing in Editor window.

Adapt the declaration of the method, so that it has no parameters and its return type is void. See Edit the return data type of the method and Delete a method parameter.

Override inherited Done() method

If there is already a Done method inherited from one of the ancestor classes:

Override this method first.

Then open the method for editing in the Editor window.

Implement the Done() method

Done() methods are implemented similarly as you do with ordinary methods. The unique limitation is, that from the destructor's implementation no other objects can be accessed nor new objects can created. In other words, the destructor can operate on the particular object only without interacting with other objects.