realbasic-betas.mbox
[Top] [All Lists]

Re: Re-entrance of events

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: Re-entrance of events
From: Karen <keatk at comcast dot net>
Date: Wed, 30 Jun 2004 23:18:10 -0400
Delivered-to: realbasic-betas at lists dot realsoftware dot com
List-help: <mailto:realbasic-betas-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Betas <realbasic-betas.lists.realsoftware.com>
List-post: <mailto:realbasic-betas@lists.realsoftware.com>
References: <BD0859EE dot 8F48%larsjensen at rcn dot com> <a05300b13bd0899ccf5b8 at [10 dot 10 dot 13 dot 3]>

On Jun 30, 2004, at 12:31 PM, Joseph J. Strout wrote:

1. Make a Timer (resp. Thread) subclass, called DelegatorTimer (DelegatorThread).

2. Make a class interface called TimerDelegate (ThreadDelegate), with one method: TimerAction( source as Timer ) (or in this case, ThreadRun( source as Thread ).

3. Now, wherever I have such a need, I just make my class implement the appropriate interface and method, and create a DelegatorTimer (you get the idea) that, in its Action (Run) event, calls the corresponding method on its delegate. This I can reuse all over the place, and the code that actually does the real work is in the class that needs it, rather than in the Timer/Thread subclass.

I've been using that method for a couple of years with timers (I called the subclass OwnedTimer and the interface TimerOwner). Very handy... You just have to be careful break the circular reference.

My Interface has two Methods:
Sub TimerAction( CallingTimer as OwnedTimer)
Sub Cleanup

Typically I look for TimerOwners in the Window CancelClose (after I call a new CancelClose event to see if the window really is closing) by scanning the control list and tell then to Cleanup.

Since we have been able to subclass windows, that mechanism has become very convenient to break the circular reference without having to think about it.

- Karen

_______________________________________________
Unsubscribe:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

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