667 views
in GUI Development by
Hello, I ran into a strange issue with using a simple timer in the Device autoobject that I used to have. It used to work great but now it works for n times and stops. n ranges from 0-9 (max). I have a Device autoobject copy in the root class of the application thinking maybe it's being garbage collected. I don't see any other ill-effects with the application, the GUI still responds to button clicks etc and I can scroll through the screens of the application no problem. Do you have any ideas as to what could be causing these issues? Thank you!

3 Answers

+1 vote
by
 
Best answer

Please see Lifetime on an autoobject.

Best regards

Paul Banach

+1 vote
by
Hello,

I think you are already found the reason - the autoobject seems to be deleted by the Garbage Collector. What do you mean with "device autoobject copy in the root class"? In order to prevent the Garbage Collector from freeing an autoobject, please add a variable to the root class, set the type to DeviceUnit::DeviceClass and the value to the instance (autoobject) of the class.

Does it work?
0 votes
by
Every autoobject is represented at the runtime by a global instance of the class, specified in autoobject's Class attribute. As such autoobjects can be involved within Chora expressions wherever an operand of this class is expected. Moreover, the properties exposed by the object can be evaluated and its methods can be invoked. The autoobject itself is identified by its full name, composed of the unit name, the autoobject member is defined inside, and the name of the autoobject member itself, both separated by :: (double colon) signs. Let's assume, your project contains a class Example::DeviceClass and an autoobject of this class named Example::Device, then following code accesses the autoobject:

// Assign the autoobject to a local variable
var Example::DeviceClass someObject = Example::Device;

// Evaluate properties and invoke methods of the autoobject
if ( !Example::Device.IsEngineRunning )
  Example::Device.StartSomeEngine();

Embedded Wizard Website | Privacy Policy | Imprint

...