@@ -342,14 +342,14 @@ class DelegateFreeAsyncWait<RetType(Args...)> : public DelegateFree<RetType(Args
342342 if (thread) {
343343 // Dispatch message onto the callback destination thread. Invoke()
344344 // will be called by the destination thread.
345- thread->DispatchDelegate (msg);
346-
347- // Wait for destination thread to execute the delegate function and get return value
348- if (msg-> GetSema (). Wait (m_timeout)) {
349- // Wait succeeded. Now acquire lock to safely read the value.
350- const dmq::LockGuard<Mutex> lock (msg-> GetLock ()) ;
351- m_success = true ;
352- m_retVal = delegate-> m_retVal ;
345+ if ( thread->DispatchDelegate (msg)) {
346+ // Wait for destination thread to execute the delegate function and get return value
347+ if (msg-> GetSema (). Wait (m_timeout)) {
348+ // Wait succeeded. Now acquire lock to safely read the value.
349+ const dmq::LockGuard<Mutex> lock (msg-> GetLock ());
350+ m_success = true ;
351+ m_retVal = delegate-> m_retVal ;
352+ }
353353 }
354354 }
355355
@@ -778,14 +778,14 @@ class DelegateMemberAsyncWait<TClass, RetType(Args...)> : public DelegateMember<
778778 if (thread) {
779779 // Dispatch message onto the callback destination thread. Invoke()
780780 // will be called by the destination thread.
781- thread->DispatchDelegate (msg);
782-
783- // Wait for destination thread to execute the delegate function and get return value
784- if (msg-> GetSema (). Wait (m_timeout)) {
785- // Wait succeeded. Now acquire lock to safely read the value.
786- const dmq::LockGuard<Mutex> lock (msg-> GetLock ()) ;
787- m_success = true ;
788- m_retVal = delegate-> m_retVal ;
781+ if ( thread->DispatchDelegate (msg)) {
782+ // Wait for destination thread to execute the delegate function and get return value
783+ if (msg-> GetSema (). Wait (m_timeout)) {
784+ // Wait succeeded. Now acquire lock to safely read the value.
785+ const dmq::LockGuard<Mutex> lock (msg-> GetLock ());
786+ m_success = true ;
787+ m_retVal = delegate-> m_retVal ;
788+ }
789789 }
790790 }
791791
@@ -1131,14 +1131,14 @@ class DelegateMemberAsyncWaitSp<TClass, RetType(Args...)> : public DelegateMembe
11311131 if (thread) {
11321132 // Dispatch message onto the callback destination thread. Invoke()
11331133 // will be called by the destination thread.
1134- thread->DispatchDelegate (msg);
1135-
1136- // Wait for destination thread to execute the delegate function and get return value
1137- if (msg-> GetSema (). Wait (m_timeout)) {
1138- // Wait succeeded. Now acquire lock to safely read the value.
1139- const dmq::LockGuard<Mutex> lock (msg-> GetLock ()) ;
1140- m_success = true ;
1141- m_retVal = delegate-> m_retVal ;
1134+ if ( thread->DispatchDelegate (msg)) {
1135+ // Wait for destination thread to execute the delegate function and get return value
1136+ if (msg-> GetSema (). Wait (m_timeout)) {
1137+ // Wait succeeded. Now acquire lock to safely read the value.
1138+ const dmq::LockGuard<Mutex> lock (msg-> GetLock ());
1139+ m_success = true ;
1140+ m_retVal = delegate-> m_retVal ;
1141+ }
11421142 }
11431143 }
11441144
@@ -1486,14 +1486,14 @@ class DelegateFunctionAsyncWait<RetType(Args...)> : public DelegateFunction<RetT
14861486 if (thread) {
14871487 // Dispatch message onto the callback destination thread. Invoke()
14881488 // will be called by the destination thread.
1489- thread->DispatchDelegate (msg);
1490-
1491- // Wait for destination thread to execute the delegate function and get return value
1492- if (msg-> GetSema (). Wait (m_timeout)) {
1493- // Wait succeeded. Now acquire lock to safely read the value.
1494- const dmq::LockGuard<Mutex> lock (msg-> GetLock ()) ;
1495- m_success = true ;
1496- m_retVal = delegate-> m_retVal ;
1489+ if ( thread->DispatchDelegate (msg)) {
1490+ // Wait for destination thread to execute the delegate function and get return value
1491+ if (msg-> GetSema (). Wait (m_timeout)) {
1492+ // Wait succeeded. Now acquire lock to safely read the value.
1493+ const dmq::LockGuard<Mutex> lock (msg-> GetLock ());
1494+ m_success = true ;
1495+ m_retVal = delegate-> m_retVal ;
1496+ }
14971497 }
14981498 }
14991499
0 commit comments