VCL components are designed to be used solely from the main thread of an application. For visual components this never presents me with any difficulties. However, I would so
Don't use TTimer
in a thread, it will never be safe. Have the thread either:
1) use SetTimer()
with a manual message loop. You don't need an HWND
if you use a callback function, but you do still have to dispatch messages.
2) use CreateWaitableTimer()
and then call WaitForSingleObject()
in a loop until the timer is signalled.
3) use timeSetEvent()
, which is a multi-threaded timer. Just be careful because its callback is called in its own thread so make sure your callback function is thread-safe, and there are restrictions to what you are allowed to call inside that thread. Best to have it set a signal that your real thread waits on an then does its work outside of the timer.