1 UINT CNrcServer::Run(LPVOID pParam) { //通过丝程传入当前类的地址 2 CNrcServer* pNrcServer = (CNrcServer*)pParam; 3 while(1) { //获取当前系统时间 4 DWORD currentTime = GetTickCount(); /* m_dwLastPlayingTime 是在一个网络正常运行线程函数中定义的变量 m_dwLastPlayingTime = GetTickCount();*/
5 signed int intervalTime = currentTime - pNrcServer->m_dwLastPlayingTime; /* 对获取的时间作为比较,如果大于5秒,视为网络断线*/
6 if (intervalTime > 5000) { 7 pNrcServer->m_bNetWorkstate = FALSE; 8 Sleep(1000); 9 pNrcServer->m_bNetworkFlag = FALSE;10 AfxEndThread(0);11 }12 }13 return 0;14 }