<br clear="all">I have a form with some threaded objects that notify another form of events by calling one of that forms events.<br><br>I want to convert to a data module and any interested object to register for those notifications.<br>
<br>My idea is for each thread to have some kind of list of procedure types and each interested object registers its routine eg.<br><br>This is the data module. It is a rough sketch and may have some syntax errors<br><br>
<blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">Type TOneArg = Procedure (Var X : integer);
<br><br>type<br> TMonitorObject = class(TThread)<br> private<br> InterestedObjects: TList<br> procedure DispatchOutput;<br> procedure DisplayRawOutput;<br> protected<br> procedure Execute; override;<br> public<br>
constructor Create(CreateSuspended: Boolean);<br> RegisterInterest(interestedProc:TOneArg);<br> end;<br><br><br>TMonitorObject.RegisterInterest(TOneArg);<br>begin<br> InterestedObjects.Add(interestedProc);<br>end;<br>
<br>procedure TMonitorObject.DispatchOutput;<br>begin<br> foreach InterestedObject do<br> InterestedObject.Procedure.Execute;<br>end;<br><br>constructor TMonitorObject.Create(CreateSuspended: Boolean);<br>begin<br> inherited Create(CreateSuspended);<br>
InterestedObjects := TList.Create<br> FCycleComplete := True;<br><br>end;<br></blockquote>
<br><br>Do the procedures for the objects which require notification need to be constructed in some way?<br><br>Am I on the right track here? I am particularly interested in what happens when the objects passing the routines are destroyed without the data module knowing about it.<br>
-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>