Jump to content

dexter

Members
  • Content Count

    6
  • Joined

  • Last visited

Everything posted by dexter

  1. Hi, I'm using the GlobalOmniThreadPool like this: CreateTask( procedure(const aTask: IOmniTask) begin FProvider.Execute(Self); end) .OnTerminated( procedure(const aTask: IOmniTaskControl) begin FEvents.FireThreadEndEvent(); end ) .Join(FTaskGroup) .Schedule; During FProvider.Execute() some DB resources are alocated (within task's thread). Questions: 1. For some reason OnTerminated() is not called at all, even when program is finished. 2. When OnTerminated is called - will it be called from thread's context, so I'll release DB resources. If not - is there any event call from thread's context at the end of execution?
  2. dexter

    Stopping a TimedTask

    Hi, In a console application I have defined a timed task, which sends an empty string once per minute to keep alive a connection: FKeepAlive := Parallel.TimedTask.Every(60 * 1000).Execute( procedure() begin FConn.SendStr(''); // will send just ENTER each minute end ); When the application is closing - I'm trying to stop the task with following code: FKeepAlive.Stop; FKeepAlive.Terminate(5000); // <-- here error is raised And I'm getting System Error: Invalid window handle How is the proper way to stop a timed task?
  3. dexter

    Stopping a TimedTask

    Same problem, fails with Invalid Window Handle during first .Terminate(1000) call.
  4. dexter

    Stopping a TimedTask

    Hi, I have updated the destructor but it did not help: FKeepAlive.Stop; while integer(PeekMessage(Msg, 0, 0, 0, PM_REMOVE)) <> 0 do begin TranslateMessage(Msg); DispatchMessage(Msg); end; FKeepAlive.Terminate(5000); And it fails during call to Terminate(5000) after about 1 second.
  5. dexter

    Stopping a TimedTask

    Hi Eddy, the problem is not in FConn. I have removed the call to FConn.SendStr('') from TimedTask execution, and the problem persists. And exception is raised during FKeepAlive.Terminate, FKeepAlive.WaitFor does not help. See attached the call stack to exception.
  6. dexter

    Stopping a TimedTask

    Hi, The full destructor code is: destructor TjBASEComm.Destroy; begin if Assigned(FKeepAlive) then try FKeepAlive.Stop; FKeepAlive.Terminate(5000); // <-- here error is raised except end; try FConn.Free; except end; inherited; end; As you can see - connection is freed after. Can it be because application is a console app?
×