Using TTimer in Threads - OnTimer event never fires.
Posted on 2000-04-25
I have created by own thread object by deriving a class from TThread and overrided the Execute method with the code to execute. As part of the thread code, I want to dynamically create a timer and fire a procedure I have written within the thread (the OnTimer event). However, the OnTimer event never fires. How to I get it to work? This is the code I have written...
timMyTimer: TTimer; // This goes in private section of TMyThread class
This is how I've created the timer at the beginning of the execute method...
timMyTimer := TTimer.Create(Main);
timMyTimer.OnTimer := OnTimerEvent;
timMyTimer.Enabled := True;
procedure TMyThread.OnTimerEvent(Sender: TObject);
// This should fire every second, but doesn't!