Talking to a thread
Posted on 1998-03-02
I've used threads in the past to do an intensive process, like a sort or a file search. In each case, they've terminated with a result. That's fine.
But how do I talk to a thread to change its state, or to change its execution path, or to trigger it to do things?
I am thinking of an object that would normally be descended from TObject, but is now descended from TThread. Some form of state machine, but one that does some heavy but short term processing or network access when the state changes.
I also need it to have some form of event-based reporting to the main thread. Is there any way to make this work without it having to wait for the main thread? In either case, how do you do it?