Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

events in objects

Status
Not open for further replies.

JeroenNL

Programmer
Nov 28, 2002
217
NL
Hi there,

I have an object which should perform certain tasks if the state of another object changes. One way of doing this is by using threads, right? If so, how is it done and are there any other ways of achieving the same thing?

Bye,
Jeroen
 
Jeroen,

I'm not sure I'd use threads for this, though you can if you like. Thread are more useful, ime, for having multiple things going on at the same time, though you have to be dealing with a machine capable enough of handling more than one process effectively. Usually this means something fast, with a lot of RAM, and running a recent version of Windows.

Instead, I think you'll want to look at properties and using custom routines to set their values. For example, in the object that changes, I'd probably create a status property. Then I'd create a setStatus methods that's used as the write procedure for that property. This lets you implement "side-effects" for what happens when the Status property changes.

For more information, use Delphi's Help system to open the Creating Custom Components book, then look for the Creating properties section and the sub-section called "The Write Method." You can do this from the Contents tab of the Delphi Help files.

Hope this helps...

-- Lance
 
It sounds like the other object needs an event that will be called when the state change occurs.
 
Thank you both for your suggestions. It seems like Loren is thinking in the same direction as I am. I have a bunch of objects (call them TMyObject) which all have a socalled TID property (type integer). I also have a bunch of other objects (TMyOtherObject). All these objects have an ID property. I can select a TMyOtherObject in my program and when I do, I need the ID of that object to be written to the TID property of the TMyObjects. Am I making sense? ;-) If so, maybe you could point out a few nice suggestions to get this working.

Thanks sofar!
Jeroen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top