2
后来是我的程序,但它不像我期望的那样工作。我希望主窗口程序调用函数“MyDllIniSys”在dll中,让dll的渲染窗口大概为32微秒,直到主窗口程序设置“bIAutoRender”不等于1. 所以我希望函数“MyDllIniSys”启动线程,并立即返回。 但是,在我所做的,该程序不会工作,如果线程开始,它将永远不会返回。 我怎样才能得到它,有人请。帮帮我。 非常感谢如何在后台使用多线程提升线程
static void renderOneFrame(const boost::system::error_code& /*e*/,
boost::asio::deadline_timer* t, int* iNeedAutoRender)
{
//call Who use this DLL, let it refresh the window
if(OnRefreshEvent)
{
OnRefreshEvent();
}
if(*iNeedAutoRender == 1)
{
t->expires_at(t->expires_at() + boost::posix_time::microseconds(iIRenderMicroSenconds));
t->async_wait(boost::bind(renderOneFrame,
boost::asio::placeholders::error, t, iNeedAutoRender));
}
}
EXTERN_C MYDLLAPI INT MyDllIniSys(INT WindowWidth,INT WindowHeight)
{
COgreRenderLoader myLoader;
myLoader.IniOgre(externalWindowHandle,WindowWidth,WindowHeight);
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::microseconds(iIRenderMicroSenconds));
t.async_wait(boost::bind(renderOneFrame,
boost::asio::placeholders::error, &t,&bIAutoRender));
boost::thread thread1(boost::bind(&boost::asio::io_service::run, &io));
//io.run();
thread1.join();
//thread1.start_thread();
return 1;
}