RTC Forums
April 24, 2024, 09:34:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: 1 [2]
  Print  
Author Topic: AniIndicator freeze on DataResult as Dataset  (Read 10320 times)
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #15 on: March 23, 2018, 01:46:28 PM »

If you are using the latest RTC SDK version (which also means that you are NOT using the "rtcFMX.GUI" or similar units somewhere in your Project), I fail to see how RTC code running in background threads could negatively affect completely unrelated visual components, unless these visual components require a large portion of the CPU and do NOT work correctly when there are background threads running and using the CPU.

Anyway ... I still claim that the problem is unrelated to the RTC SDK, but since your problem is with the "TAniIndicator" component and you are using RTC components with background threads, you might want to "google" to see if anyone else has problems with that component when using threads and running code in the background.
Logged
bebeantics
RTC License+
****
Posts: 29


« Reply #16 on: March 23, 2018, 08:55:39 PM »

THIS IS JUST A WORKAROUND

My solution was the following

tha rtcclientmodule is in a datamodule.

procedure Tdt.RtcClientModule1ResponseDone(Sender: TRtcConnection);
begin
if mainform.AniIndicator2.Visible then
    if not mainform.Text4.Visible then begin
        MainForm.AniIndicator2.Visible:=false;
        mainform.AniIndicator2.Enabled:=false;
        mainform.Text4.Visible:=true;
    end;
end;

on the rtcresult site, i delete everything was relative to aniindicator and remaining just this.
....
else if (Data.isType=rtc_Function) and (Data.asFunction.FunctionName='getretur') then begin

                 if Result.isType = rtc_Dataset then begin

                      dt.rtcmdsretur.asDataSet := Result.asDataSet;
                      Result.Extract;

                      dt.rtcMdsretur.Active := True;
                      lwproduseretur.Visible:=true;
                 end
                 else if result.isType=rtc_exception then
                      showmessage(result.asException);
end;

Somehow Result.Extract invokes an event of ending the reception of information, although the records have not yet been received (or transferred to rtcmdsretur)
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #17 on: March 24, 2018, 11:41:55 AM »

The "Result.Extract" method does NOT invoke any events. The "Extract" method simply removes a pointer to the object contained within "Result", so the object (asDataSet - in your case) won't be destroyed when the "Result" object is destroyed. And since the pointer to the object contained within "Result" was removed, any data previously stored in the "Result" object can also NOT be accessed using the "Result" object after calling "Extract". But ... judging by your code, this was intended, so I don't see any problems there.

I hope you didn't completely remove your code for synchronizing your events with the Main Thread. Any code accessing any visual components and/or controls HAS TO be called from the Main Thread, or it won't work correctly. Since you are using the TRtcHttpClient component with "MultiThreaded:=TRUE", any events you assign to that TRtcHttpClient component or any other components linked to it (like the TRtcClientModule component you are using to call remote functions) will be executed from background threads, unless you use the "Sender.Sync" method to synchronize your event with the Main Thread (as you did before), or set "AutoSyncEvents:=TRUE" for all RTC components with events accessing the GUI (visual components or controls).
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #18 on: March 24, 2018, 12:05:59 PM »

Based on your "workaround", I think I understand now what your actual problem was.

You've placed multiple remote function calls into the queue and have enabled the "TAniIndicator" component before placing each remote function call into the queue, but have disabled the "TAniIndicator" immediately after receiving the first result from the Server, ignoring the fact that other remote calls could still be waiting in the queue with more results to come later.

Because of that, it probably appeared to you as if the "TAniIndicator" component "froze", while in fact it was working until the 1st result arrived, after which you've disabled it, so that it was no longer working when other remote calls were being sent and/or their results received.

Since you are using RTC components in Multi-Threded and Asynchronous event-driven mode, you can place any number of requests and/or remote function calls into the queue instantly, but they will all be sent out (later) serialized, one after the other, with their results arriving in the same way. First the result from the 1st remote call, then from the 2nd and so on.

If you want to show an animation on the Client when data is being sent and/or received, you can use the "OnBeginRequest" event to enable your animation and then use "OnResponse*" events to disable that animation (there are multiple events there, depending on what happened with the response). Because of the asynchronous nature of RTC components and the way you are using them, this would actually be the most correct way to achieve what you wanted.
Logged
Pages: 1 [2]
  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 16 queries.