RTC Forums
April 29, 2024, 10:23:47 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RTC Delayed Calls on the Server  (Read 3194 times)
Ronald van Tour
RTC License++
*****
Posts: 37


« on: March 26, 2012, 09:35:53 PM »

Hi Danijel,

Can you give your comment on below code  that also will do a delayed call on the server

procedure TForm9.RtcFunction1Execute(Sender: TRtcConnection;
  Param: TRtcFunctionInfo; Result: TRtcValue);
begin
  with sender as trtcdataserver do
  begin
     repeat
       result.asString:='hello' +param.asstring['name'];
       Application.ProcessMessages;
     until 'some condtion is true'
  end;
end;
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: March 26, 2012, 10:17:28 PM »

First, you should NEVER EVER use "Application.ProcessMessages" from within RTC events, because this can result in unexpected inner loops, caused by windows messages! And second, using loops inside RTC events to wait for "some condition" is also a bad idea, because you are suspending a connection and blocking a thread this way. These rules apply to single-thread as well as multi-threaded applications.

There are already several threads in this forum explaining how Delayed Calls work, and how they should be used.

Here are the most relevant topics:

How to work TRtcDelayedCall?
Streaming headlines...
Messenger example and delayed calls

Should you have more questions after checking these topics, please ask.

Best Regards,
Danijel Tkalcec
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.022 seconds with 16 queries.