[Lazarus] Message Loop paused when no interaction with mouse?

Bernd prof7bit at googlemail.com
Thu Apr 21 16:56:29 CEST 2011


On Apr 20, 2011 7:52pm, Bernd <prof7bit at googlemail.com> wrote:

> I have tried QueueAsyncCall and Synchronize() both don't work here.
> PostMessage() works.

I have now done the following to "simulate" a Synchronize()
with the help of PostMessage()

This seems to work without problems, without crashing, without noticeable
strange behavior and is running smoothly. Is the following usage of
RTLeventWaitFor correct or am I abusing/missing something and
calling for trouble?


in my worker thread I have:

begin
  GuiHasFinishedEvent := RTLEventCreate;

  while...
  begin

    // wite to the image
    // Image.Picture.Bitmap.RawImage.Data[somewhere] := something;

    // frame is complete, notify GUI
    RTLeventResetEvent(GuiHasFinishedEvent);
    PostMessage(Application.MainForm.Handle, MM_FRAME_COMPLETE, 0, 0);
    RTLeventWaitFor(GuiHasFinishedEvent);
  end;

  RTLeventdestroy(GuiHasFinishedEvent);
end;


and in my Form:


TMainForm = class(TForm)
  procedure OnCameraFrame(var Msg); message MM_FRAME_COMPLETE;
  ...


procedure TMainForm.OnCameraFrame(var Msg);
begin
  // it is alaways in updatig state, only release this for a short moment
  Image.Picture.Bitmap.EndUpdate();
  Image.Picture.Bitmap.BeginUpdate();

  // the camera thread is waiting, notify it that we are done.
  RTLeventSetEvent(GuiHasFinishedEvent);
end;




More information about the Lazarus mailing list