|
|
|
|
|
- Overview
- Low references and strong references
- Example of references
- Strong reference
- Weak reference
- Forced destructor
- Equivalence
Advanced management of class instances
The advanced management of instances is used to choose the mode for taking reference. This choice has a direct impact on the release of class objects: depending on the reference selected, the "Destructor" will not be called at the same time.. Two modes are available for taking reference: - the low reference.
- the strong reference.
Reminder Search Engine Optimization: Referencing allows you to reference the same data zone as the source element. For example, two variables point to the same class object. To reference an object, all you have to do is use the <- operator. Important: In all cases, you can force a call to the destructor using the "Release" keyword.
Low references and strong references Two types are available for taking reference: - The strong reference (default): In this case, the class object will be released only when all object references have been released.
- The weak reference: In this case, objects will be released automatically according to their scope (even if a global reference has been taken on these objects).. The low reference must be specified during the dynamic instantiation of the object taking reference.
To specify a low reference, use the following syntax: Reference is dynamic object Class1, weak or: Reference is dynamic object Class1 <weak> Remark: It is possible to force the weak reference for all objects with the following syntax: ExecutionMode(ForceDestructorNonDynamicObject)
Caution: This operation is global to the entire application and may disrupt component operation. Strong reference At the end of the procedure, the "MyObject" object is not freed (the destructor is not called). The "MyObject" object will be freed when "GlobalReference" is freed. Therefore, "MyObject" will be freed when the window is closed.
GlobalReference is dynamic object Class1
PROCEDURE LocalWindowProcedure()
MyObject is object Class1
GlobalReference <- MyObject
Weak reference At the end of the procedure, the "MyObject" object is freed (the destructor is called) and "GlobalReference" is set to NULL.
GlobalReference is dynamic object Class1, weak
PROCEDURE LocalWindowProcedure()
MyObject is object Class1
GlobalReference <- MyObject
You have the ability to force the call to the destructor (free the object) even if a strong reference was taken on this object. The following syntax is used to force the call to the destructor:
MyObject is object Class1, force Destructor
or:
MyObject is object Class1 <force Destructor>
Equivalence the following codes (example 1 and example 2) are equivalent. In both cases, the object will be freed at the end of the procedure. Example 1:
GlobalReference is dynamic object Class1, weak
PROCEDURE LocalWindowProcedure()
MyObject is object Class1
GlobalReference <- MyObject
Example 2:
GlobalReference is dynamic object Class1
PROCEDURE LocalWindowProcedure()
MyObject is object Class1, force Destructor
GlobalReference <- MyObject
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|