Page tree
Skip to end of metadata
Go to start of metadata

template<class Functor >
Functor::result_type FB::BrowserHost::CallOnMainThread ( Functor  func) const

Execute a call on the main thread, wait for the result, and return it.

With this template function calls can be made on the main thread like so:

try {
int result = host->CallOnMainThread(boost::bind(&ObjectType::method, obj, arg1, arg2));
} catch (const FB::script_error&) {
// The call will throw this exception if the browser is shutting down and it cannot
// be completed.
}

This is a synchronous cross-thread call, and as such may have a performance penalty.

Parameters
funcThe functor to execute on the main thread created with boost::bind
Returns
The return value from the call
Exceptions
FB::script_error
See Also
ScheduleOnMainThread
Since
1.3.0

Definition at line 217 of file CrossThreadCall.h.

218  {
219  boost::shared_lock<boost::shared_mutex> _l(m_xtmutex);
220  return CrossThreadCall::syncCall(shared_from_this(), func);
221  }
  • No labels