The VCL (and parts of the RTL) is not thread-safe, so you cannot move components around from a thread. You have several options:
- Use a
TTimercomponent. You don't need a thread and the timer's event handler will be executed in the context of the main thread. The timer was designed exactly for things like that. - Synchronize all VCL related stuff in the thread.
TThreadprovides a static methodSynchronizethat does exactly that. - Send messages from the thread to the form using
SendMessageorPostMessageand handle this message in the form.
You might also consider to use the TThread wrapper class instead of using BeginThread and EndThreadexplicitly when working with threads.
Smasher
2010-03-24 14:12:51