Re: [Lazarus] TThread.Synchronize

2016-11-08 Thread Michael Schnell via Lazarus
On 25.10.2016 14:07, LacaK via Lazarus wrote: Yes this can happen. MyForm.MyMethod is called also from event handler and also is used in Synchronize(@MyForm.MyMethod) How can this happen/play role? I suppose by "event handler" you mean a GUI event (Mouse, Keyboard, ...) Such events are servic

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread Mattias Gaertner via Lazarus
On Wed, 26 Oct 2016 20:23:11 +0200 Sascha Hestermann via Lazarus wrote: > Am 26.10.2016 um 12:02 schrieb LacaK via Lazarus: > > Btw. when TTimer is executing OnTimer method, which does not finishes > > until next Interval is elapsed, is again called OnTimer ? Or next > > OnTimer is performed only

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread Sascha Hestermann via Lazarus
Am 26.10.2016 um 12:02 schrieb LacaK via Lazarus: > Btw. when TTimer is executing OnTimer method, which does not finishes > until next Interval is elapsed, is again called OnTimer ? Or next > OnTimer is performed only when prior OnTimer finished ? Afaik TTimer periodically sends a message to the e

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread Michael Schnell via Lazarus
On 26.10.2016 12:02, LacaK via Lazarus wrote: you just could use TTimer. probably yes. I do not remember why I have used thread for it. May be I do not wanted dependency on ExtCtrls ... Btw. when TTimer is executing OnTimer method, which does not finishes until next Interval is elapsed, is

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread LacaK via Lazarus
Dňa 26.10.2016 o 11:17 Michael Schnell via Lazarus napísal(a): On 26.10.2016 07:57, LacaK via Lazarus wrote: procedure TRefreshFileListThread.Execute; begin while not Terminated do begin Synchronize(@MyForm.UpdateFileList); // UpdateFileList is method which clears listbox and then adds fi

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread Michael Schnell via Lazarus
On 26.10.2016 07:57, LacaK via Lazarus wrote: procedure TRefreshFileListThread.Execute; begin while not Terminated do begin Synchronize(@MyForm.UpdateFileList); // UpdateFileList is method which clears listbox and then adds files in given shared folder Sleep(1); end; This only m

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread LacaK via Lazarus
Big Thanks to all. Now I understand what is happening ... probably I wil use critical section to block access from thread when code in main thread is performed ... -Laco. ShowModal() for a modal form will call it. [...] I did test in Delphi and Delphi seems also perform synchronize upon Sho

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread Mattias Gaertner via Lazarus
On Wed, 26 Oct 2016 09:49:44 +0200 LacaK via Lazarus wrote: > >>> ShowModal() for a modal form will call it. >[...] > I did test in Delphi and Delphi seems also perform synchronize upon > ShowModal Yes. > > Nowhere is it stated or guaranteed that synchronisation cannot happen > > in a GUI

Re: [Lazarus] TThread.Synchronize

2016-10-26 Thread LacaK via Lazarus
ShowModal() for a modal form will call it. Ah really? It happens in my application! Then that is your problem. :-))) But is it correct behavior ? IMO it is against thread safety, which should Synchronize guarantee! The two issues are completely unrelated. The current behaviour is co

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Michael Van Canneyt via Lazarus
On Wed, 26 Oct 2016, LacaK via Lazarus wrote: Check for Application.ProcessMessages and CheckSynchronize calls. These process synchronize queue, if I am not mistaken. I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread LacaK via Lazarus
Check for Application.ProcessMessages and CheckSynchronize calls. These process synchronize queue, if I am not mistaken. I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call it in background ? ShowModal() for a modal form

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Mattias Gaertner via Lazarus
On Tue, 25 Oct 2016 15:02:06 +0200 LacaK via Lazarus wrote: > >> I do not call CheckSynchronize nor ProcessMessages in my application. > >> So only any LCL component or widget set can call it in background ? > > > > It should be easy for you to set a breakpoint into MyForm.MyMethod and > > che

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Mattias Gaertner via Lazarus
On Tue, 25 Oct 2016 13:37:03 +0200 Michael Schnell via Lazarus wrote: > > If you don't call CheckSynchronize within MyForm.MyMethod then yes. > IMHO the (hardly documented) CheckSynchronize should not be called > directly by an application that uses a Widget Type that features an > Event Que

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread LacaK via Lazarus
I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call it in background ? It should be easy for you to set a breakpoint into MyForm.MyMethod and check the call stack. But error (AV) happens only in production and only sometime

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Michael Van Canneyt via Lazarus
On Tue, 25 Oct 2016, LacaK via Lazarus wrote: Check for Application.ProcessMessages and CheckSynchronize calls. These process synchronize queue, if I am not mistaken. I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call it i

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Ondrej Pokorny via Lazarus
On 25.10.2016 14:12, LacaK via Lazarus wrote: I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call it in background ? It should be easy for you to set a breakpoint into MyForm.MyMethod and check the call stack. Ondrej -- _

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread LacaK via Lazarus
Check for Application.ProcessMessages and CheckSynchronize calls. These process synchronize queue, if I am not mistaken. I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call it in background ? From Delphi doc: "Synchronize c

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread LacaK via Lazarus
Check for Application.ProcessMessages and CheckSynchronize calls. These process synchronize queue, if I am not mistaken. I do not call CheckSynchronize nor ProcessMessages in my application. So only any LCL component or widget set can call it in background ? -Laco. -- ___

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread LacaK via Lazarus
My understanding is that, Synchronize schedules execution of MyForm.MyMethod to main thread, so method is not executed until control is returned from event handler in MyForm. Right? TThread.Synchronze pushes the procedure that is given as a parameter (including it's Self pointer) to the even

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Michael Schnell via Lazarus
If you don't call CheckSynchronize within MyForm.MyMethod then yes. IMHO the (hardly documented) CheckSynchronize should not be called directly by an application that uses a Widget Type that features an Event Queue. Here the user should do "Application.ProcessMessages", that is decently docu

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Michael Schnell via Lazarus
On 25.10.2016 13:21, LacaK via Lazarus wrote: My understanding is that, Synchronize schedules execution of MyForm.MyMethod to main thread, so method is not executed until control is returned from event handler in MyForm. Right? TThread.Synchronze pushes the procedure that is given as a paramete

Re: [Lazarus] TThread.Synchronize

2016-10-25 Thread Ondrej Pokorny via Lazarus
On 25.10.2016 13:21, LacaK via Lazarus wrote: I have form on which is button. When user clicks button OnClick event handler is called (it is method of form). Processing of this method takes some time say 1 minute. In the background is operating another thread which every 10 seconds calls Synchr