Reputation: 998
For example from thread provided by callback from CreateTimerQueueTimer in executable or dll? It is significant to have same thread id as main thread.
procedure TMyMainClass.ExecuteMe(someparam: paramtype);
begin
{something}
end;
and
procedure TimerCallback(pvContext: pointer; fTimerOrWaitFired: boolean); stdcall;
begin
{do what ?}
end;
Final update:
All this stuff (TThread.Synchronize
, TThread.Queue
, PostThreadMessage
etc) works through messages. So be sure host application of your dll
processing messages while waiting for callback.
Upvotes: 6
Views: 3359
Reputation: 612993
To execute code in the main thread, without access to a TThread
instance, call the class methods TThread.Synchronize
or TThread.Queue
.
If you happen to be using an old Delphi compiler that does not have those methods, then SendMessage
or PostMessage
with a user defined message are the simplest solution.
Upvotes: 8