[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Here is a program exploring Delphi's TThreads class as the mechanism to run independent processes. In this case, I've implemented the rudiments of an elevator simulator. TElevator is a TThreads descendant which visually moves from floor to to floor, opening its doors at each stop. This is the basis for an Elevator Simulation program currently being developed. Several days trying to implement elevator controls using queues and lists convinced me that perhaps I have finally found an application suitable for thread processing. Here are the tricks I've learned so far about using threads.
The rest of the code is not trivial, but not too complex either. I made an array of buttons to move the elevators one floor per push. Only the buttons corresponding to the current number of elevators are made visible. The TImage, Image1, is used only to provide a convenient way to define the field for floors and elevators. It remains invisible in order to speed up the drawing the other elements. A timer is used to periodically check how long each elevators doors have been open to close them when the specified "Door open" time has passed. I've learned quite a bit in the process of coding this. Perhaps you will too!
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |