Mike at Bookup
Mike at Bookup

Reputation: 1324

Do timer events in Delphi happen in their own thread?

When a Delphi timer executes, is it not in the main thread?

procedure TMainForm.MyTimerTimer(Sender: TObject);
begin
      MyModalDialog.StatusText.BeginUpdate;
      MyModalDialog.StatusText.Text := 'timer fired...';
      MyModalDialog.StatusText.EndUpdate;
end;

I am wondering if crashes here are due to updating the GUI elements outside of the main thread.

Upvotes: 0

Views: 280

Answers (2)

fpiette
fpiette

Reputation: 12322

The timer event handler execute in the context of the thread having created it. Usually it is the main thread but you can create a timer within any thread.

Upvotes: 4

Z .
Z .

Reputation: 12837

The timer will execute on the main thread. No need to worry about using Synchronize().

Upvotes: 1

Related Questions