On Apr 20, 2011 7:52pm, Bernd <[email protected]> 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;
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus