后部分是我的程序,但它没有按我的预期工作。我希望 dll 中的主窗口程序调用函数“MyDllIniSys”,让 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;
}