RTC Forums
May 05, 2024, 07:49:22 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcDelayedCall from within a thread  (Read 4337 times)
johannc
RTC License++
*****
Posts: 7


« on: May 18, 2010, 09:26:01 PM »

Are there any known issues with calling a TRtcDelayedCall from within a thread other than the main thread? I seem to have an issue where if I do, then Wakeup no longer immediately call the event but the event will be called after the timeout period; especially after subsequent calls to the server. If I wrap the call in a CriticalSection it works properly all the time. Just wanted to know.

Thanks.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: May 18, 2010, 10:05:45 PM »

I'm not sure I understand your question. Are you asking if there are issues with using the "WakeUp" method of the TRtcDelayedCall object from background threads?

If that's what you are asking, then the answer is that the WakeUp method should work from anywhere, but it may ONLY be used once and ONLY if the TRtcDelayedCall object wasn't already destroyed (for example, because the connection timed out or the timeout set for the TRtcDelayedCall occured).

If everything works fine when you place the WakeUp call inside a CriticalSection and you make sure the object is not used ANYWHERE after the WakeUp call, chances are that the same TRtcDelayedCall object was being accessed from multiple threads at the same time, which is definitely something that you should NOT allow.

Best Regards,
Danijel Tkalcec
Logged
johannc
RTC License++
*****
Posts: 7


« Reply #2 on: May 18, 2010, 10:09:36 PM »

Yes that's exactly what I was asling sorry. Yeah wanted to know if calling Wakeup from background threads was a no-no. What I haven't done however is to remove the object after Wakeup. That I will implement now.

Thanks for your quick reply.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: May 18, 2010, 10:14:48 PM »

Just to clarify: By "remove the object" I meant that you should remove the pointer to the TRtcDelayedCall object, so you do NOT try to use it again. But you should NOT try to Free/Destroy the TRtcDelayedCall object, because it will be destroyed by the RTC SDK.

Best Regards,
Danijel Tkalcec
Logged
johannc
RTC License++
*****
Posts: 7


« Reply #4 on: May 18, 2010, 10:18:35 PM »

No no no, not free or destroy. It is kept in a container and I will remove it's identifier from the container.
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 18 queries.