RTC Forums

Subscription => Support => Topic started by: Ronald van Tour on March 26, 2012, 09:35:53 PM



Title: RTC Delayed Calls on the Server
Post by: Ronald van Tour 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;


Title: Re: RTC Delayed Calls on the Server
Post by: D.Tkalcec (RTC) 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? (https://rtcforum.teppi.net/index.php?topic=135.0)
Streaming headlines... (https://rtcforum.teppi.net/index.php?topic=61.0)
Messenger example and delayed calls (https://rtcforum.teppi.net/index.php?topic=632.0)

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

Best Regards,
Danijel Tkalcec