Getting Delphi TTimer to work with a multi-threaded application

I have a problem with a simple TTimer that is triggered and has an OnTimer event in the main thread of the application , the code looks like this:

procedure TForm1.DoSomeStuff();
begin
     OmniLock.Acquire;
     try
        Parallel.Pipeline.NumTasks(MaxThreads).Stage(StageProc).Run;

        if (MyTimer = nil) then
        begin
             MyTimer := TTimer.Create(nil);
             MyTimer.Interval := 60 * 1000;  // timer fired every 60 seconds
             MyTimer.OnTimer := MyTimerEvent;
             MyTimer.Enabled := True;
         end;
      finally
             OmniLock.Release;
      end;    // try/finally
 end;

Everthing works fine when I execute code in a simple project / demo, but in my application (which uses Omni Thread Library v3) the timer event never fires

I am sure that this is nothing , I just can not understand what is wrong!

I triple checked: MyTimerassigned only once in my code, its OnTimer event is correctly assigned, etc.

I am using Delphi 2010

Does anyone know how to fix this?

+3
source
1

TTimer - , . TTimer, , TTimer WM_TIMER.

TTimer . WM_TIMER, HWND . VCL AllocateHWnd(), .

, CreateWindow() , / WM_TIMER, , timeSetEvent(), Sleep() WaitForSingleObject(). , , , .

+7