0

在我的插件中,我想启动新线程并从中获取回调:

我有

function myCallback()

我想从插件中的线程每 2 秒调用一次。

我该怎么做?

// this method calls from html-page:
void MyFirstPluginAPI::testEvent()
{
  //fire_test();
  // thread starting:
  boost::thread my_thread(boost::bind(&MyFirstPluginAPI::hello_world, this));
}
void MyFirstPluginAPI::hello_world() 
{
  for(;;)
  {
    boost::posix_time::seconds SleepTime(2);
    boost::this_thread::sleep(SleepTime);
    // here i must call InvokeAsync("myCallback",FB::variant_list_of(0));
    // how can i to do it?
  }
}

非常感谢。

4

1 回答 1

0

是真的答案吗?从插件到浏览器/html页面是真正的异步回调吗?

也许,我解决了这个问题。

我不使用InvokeAsync,我制作“信号”:

FB_JSAPI_EVENT(event1, 0, ());

然后我发出“信号”

fire_event1();

我在现场收到“信号”

addEvent(plugin(), 'event1', function(){
  elem = document.getElementById('mydiv');
  elem.innerHTML = elem.innerHTML + "hello<br>";
});

我会随时对此进行测试,然后我会将这个问题标记为已解决。

于 2013-04-23T13:34:09.530 回答