Lazarus

Programming => Widgetset => Other => Topic started by: dieselnutjob on October 28, 2014, 11:39:43 pm

Title: fpgApplication.ProcessMessages from a thread
Post by: dieselnutjob on October 28, 2014, 11:39:43 pm
I have a second thread which is a timer thread.  Basically it just does this
Code: [Select]
while (not Terminated) do
  begin
    Synchronize(@UpdateGui);
    sleep(100);
  end;

This causes some code to poll other stuff, in other threads, so that the gui can control them and update results etc.

The problem has been that occasionally this thread would not terminate.  I tracked it down (I think) to a procedure that was called by the polling thing which had an fpgApplication.ProcessMessages in it.

It seems that sometimes when the thread is terminated it just stalls on the fpgApplication.ProcessMessages rather than quitting out.  It never seems to cause a problem at any other time.

Can anyone shed any light on this?
Title: Re: fpgApplication.ProcessMessages from a thread
Post by: Fred vS on October 29, 2014, 01:31:00 am
Hello.

Have you try with queue() instead of synchronize() ? (but you need fpc 2.7.1)

I had some problem with  synchronize() and queue() does the work much better.

A other thread-safe (and very fast) method is to use the build-in fpGUI SentMessage().

Fre;D


   
TinyPortal © 2005-2018