Skip to end of metadata
Go to start of metadata

template<class C , class Functor >
void FB::BrowserHost::ScheduleOnMainThread ( const boost::shared_ptr< C > &  obj,
Functor  func 
) const [inline]

Schedule a call to be executed on the main thread.

With this template function a call can be scheduled to run asynchronously on the main thread like so:

 try {
     boost::shared_ptr<ObjectType> obj(get_object_sharedptr());
     host->ScheduleOnMainThread(obj, 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.
 }

Note that the first parameter should be a shared_ptr to the object the call is made on; this is then used to create a weak_ptr so that if the object goes away before the call is made the call can fail silently instead of crashing the browser.

Parameters:
obj A boost::shared_ptr to the object that must exist when the call is made
func The functor to execute on the main thread created with boost::bind
Exceptions:
FB::script_error 
See also:
CallOnMainThread
ScheduleAsyncCall
Since:
1.3.0

Definition at line 224 of file CrossThreadCall.h.

00225     {
00226         boost::shared_lock<boost::shared_mutex> _l(m_xtmutex);
00227         CrossThreadCall::asyncCall(shared_from_this(), obj, func);
00228     }    


Generated on 19 Jun 2013 for FireBreath by  doxygen 1.6.1
Labels
  • None