RTC Forums
November 01, 2024, 04:46:24 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Sync in execute function  (Read 4193 times)
HelgeLange
RTC Expired
*
Posts: 100


« on: June 29, 2015, 02:38:36 AM »

Hi Danijel.. it's me.. again.. Cheesy

We tried today all day long to find a strange error :

We have a server (TRtcHttpServer) that works just fine, it's set to multi threaded and we tried to implement the sync method. The moment we place a sync in the OnExecute of a function, it's will get stuck there.

Server properties are like this :

And as I said, it works fine if we don't try to sync events.

The code that doesn't work looks like that:



It gets stuck at the Sender.Sync ...

Any ideas ?
Thanks in advance, Helge
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: June 29, 2015, 10:36:21 AM »

1. Is this a Windows VCL Application?

If it is NOT a Windows VCL Application, then the Sync method won't be working unless you use the appropriate GUI synchronization unit from RTC (for example, the "rtcFMX.GUI" unit for FireMonkey Applications compiled with Delphi XE2 and later).

2. What is happening in the Main Thread when the Sync method is called?

Is it possible that your Main Thread is busy? When the Sync method is called, a message is sent to the Main Thread with the information required to execute the event there. This is done by using the standard TThread.Synchronize method from Delphi when you are working with the VCL, or by using a TTimer component from Delphi when working with FireMonkey (where the TThread.Synchronize method isn't very reliable). In either case, the Sync method will be blocking until the event completes execution in the Main Thead, which can't happen if the Main Thread is busy or if there is no "message loop" in the Main Thread (which is required in Windows Applications and could be the case if there are no visible Windows in your Application). After the event completes execution in the Main Thread, the Sync method will also finish.

Best Regards,
Danijel Tkalcec
Logged
HelgeLange
RTC Expired
*
Posts: 100


« Reply #2 on: June 29, 2015, 01:46:54 PM »

We could solve the problem finally. It seems that the VCL (it wasn't a FMX problem) does not create a handle for a frame when the frame is not visible yet and that causes some kind of block in the message loop.

Thanks anyway Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 17 queries.