Recent

Author Topic: fpgApplication.ProcessMessages from a thread  (Read 5149 times)

dieselnutjob

  • Full Member
  • ***
  • Posts: 217
fpgApplication.ProcessMessages from a thread
« 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?

Fred vS

  • Hero Member
  • *****
  • Posts: 3362
    • StrumPract is the musicians best friend
Re: fpgApplication.ProcessMessages from a thread
« Reply #1 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


   
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018