D.Tkalcec (RTC)
|
|
« Reply #1 on: February 05, 2019, 11:14:52 AM » |
|
If your communication component is Multi-Threaded, then all OnExecute events on all TRtcFunction components linked to that component will be called from background threads. If you want to access the GUI from within your event, you need to synchronize your event with the Main Thread. IOW, if you want to access a listbox on your form from within your "feedback_fnExecute" event, you should add a call to the "Sync" method at the top of your event, like this ...
procedure TrtcClient_dm.feedback_fnExecute(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue); var txt:string; begin
if Sender.Sync(feedback_fnExecute,Param,Result) then Exit;
txt:=param.asValue['txt'];
if assigned(myform) then begin aform.alistbox.Items.Add(txt); end; end;
... the "Sync" method checks if the code is being executed from a background RTC thread. If it is, then the event (which is provided as the 1st parameter) will be called with the rest of the parameters in the Main Thread, after which the Sync method will be returning TRUE as the result. If the code is being executed from the Main Thread, then the Sync method does nothing and returns FALSE. As a result, using this line of code at the beginning of your event ensures that the rest of your event code will be executed from the Main Thread.
If this does NOT solve your problem, then I need more details about the exact communication flow. In other words, I need the complete picture and not just the code of the event that results in freezing your desktop app. Since you've mentioned a Server calling a remote function on the Client, I need to know exactly how the Client is making the original call to the Server and how the Server is triggering this "callback".
|