realbasic-nug
[Top] [All Lists]

Circular reference powers used for good?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Circular reference powers used for good?
From: Eric Williams <eric at oxalyn dot com>
Date: Sun, 30 Dec 2007 22:59:26 -0800
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Hello list -

I have a situation which, oddly enough, seems to call for a circular  
reference, and I wanted some feedback on whether it's a good idea or  
not.

The app needs to send it self a slightly delayed message - say, after  
a few seconds. I'm planning to deploy a Timer that calls back to an  
object's HandleTimedAction method. It's possible that several of  
these little timers could be necessary at once, and I don't want to  
keep track of them if I don't have to.

Can I set up the timer with a property "myself as Timer" to make sure  
it doesn't go out of scope? Then, in the Timer's Action event, I can  
set the myself property to nil and it should just evaporate after the  
event ends (because no other object will hold a reference to it).

Does anybody see any problem with this approach? Incidentally, I'm  
considering the circular reference setup to avoid a potential stack  
overflow. :)

Eric Williams
Oxalyn Software
http://software.oxalyn.com/

AE Monitor
http://software.oxalyn.com/AEMonitor/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>