Forum > Other

fpgApplication.ProcessMessages from a thread

(1/1)

dieselnutjob:
I have a second thread which is a timer thread.  Basically it just does this

--- Code: ---while (not Terminated) do
  begin
    Synchronize(@UpdateGui);
    sleep(100);
  end;

--- End code ---

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?

Fred vS:
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


   

Navigation

[0] Message Index

Go to full version