DWORD StartTick;
//一个延时循环
for(;Step<200;Step++)
{
StartTick = GetTickCount();
/*这一段为线程交出部分运行时间以让系统处理其他事务*/
for(;GetTickCount()-StartTick<10;)
{
if(PeekMessage(&Msg,NULL,0,0,PM_NOREMOVE) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
/*把运行情况打印到桌面,这是vcbear调试程序时最喜欢干的事情*/
sprintf(Buffer,"Running %04d",Step);
if(hDC!=NULL)
TextOut(hDC,30,50,Buffer,strlen(Buffer));
}
/*延时一段时间后调用回调函数*/
(*gCallback)(Step,1);
/*结束*/
::ReleaseDC (HWND_DESKTOP,hDC);
return 0;
}