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>
|