Recent

Author Topic: Synchronize() seems to not work in Total Commander plugin  (Read 705 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Synchronize() seems to not work in Total Commander plugin
« on: March 25, 2022, 02:14:41 pm »
CudaLister is a adapt of 'CudaText' as the Total Commander plugin. Ie DLL for Windows x32/x64.
I have 2-threads work, 2nd thread calls Synchronize().
I see in the debugger, that Synchronize() call don't give the effect! ie, the param (function) is not callled at all, ie breakpoint in that function don't work.

Is this a known issue?

Free Pascal Compiler version 3.3.1-9667-g222a41be7b [2021/11/28] for i386
« Last Edit: March 25, 2022, 02:21:16 pm by AlexTP »

korba812

  • Sr. Member
  • ****
  • Posts: 304
Re: Synchronize() seems to not work in Total Commander plugin
« Reply #1 on: March 25, 2022, 03:14:53 pm »
I assume you are using LCL. If so, you must periodically call Application.ProcessMessages method in main thread.
If you are not using LCL then you must periodically call procedure CheckSynchronize, also from the main thread.

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: Synchronize() seems to not work in Total Commander plugin
« Reply #2 on: March 25, 2022, 03:18:41 pm »
Is it (need to call ProcessMessages in LCL) needed only for DLL? or for any task? In the usual app, I don't do it.
In the DLL, I don't too.

korba812

  • Sr. Member
  • ****
  • Posts: 304
Re: Synchronize() seems to not work in Total Commander plugin
« Reply #3 on: March 25, 2022, 03:26:47 pm »
The DLL library has its own message queue (handled by TApplication) that is not tied to the main application queue. To process messages from the TApplication queue in the DLL library, you must periodically call Application.ProcessMessages.

Of course, you don't need to do this in a regular LCL app.

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: Synchronize() seems to not work in Total Commander plugin
« Reply #4 on: March 25, 2022, 03:34:31 pm »
Great! It helped me.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1144
    • Lebeau Software
Re: Synchronize() seems to not work in Total Commander plugin
« Reply #5 on: March 25, 2022, 06:47:36 pm »
I assume you are using LCL. If so, you must periodically call Application.ProcessMessages method in main thread.
If you are not using LCL then you must periodically call procedure CheckSynchronize, also from the main thread.

However, if the main thread is in the EXE and the Synchronize() call is in the DLL, you need to call CheckSynchronize() from inside the DLL, not from inside the EXE, since the EXE and DLL will likely be operating on separate RTL instances, and thus using separate Synchronize() queues.  In this case, the DLL would have to export a function to call its version of CheckSynchronize(), and then the EXE would have to call that exported function periodically, such as in a Timer, or a TApplication.OnIdle handler, etc.  Calling Application.ProcessMessages() in the EXE would not cut it.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: Synchronize() seems to not work in Total Commander plugin
« Reply #6 on: March 25, 2022, 07:27:36 pm »
My case is:
EXE: Total Commander. I cannot affect it.
DLL: main thread: painting of text editor; 2nd thread: text parser.

Now what I did: I started the timer from DLL main thread which calls App.ProcessMessages.

 

TinyPortal © 2005-2018