1.当参数为NULL时(大多数情况下),返回值是从1970年1月1日至今所经历的时间(以秒为单位),把下面的代码放在一个线程或者while循环下,定时执行某函数,见下面的代码:
int DELAY_TIME;
bool bFirst_time;
int cost_time ;
time_t startTm, endTm;
bFirst_time = true;
if(DELAY_TIME > 0)
{
if (bFirst_time)
{
time(&startTm);
//printf("Use Time:%d\n", startTm);
bFirst_time = false;
}
time(&endTm);
cost_time = endTm - startTm;
//printf("cost_time:%d\n", cost_time);
if (cost_time > DELAY_TIME)
{
for(size_t i = 0 ; i < yaoxin_list.size() ;i++)
{
DWORD index = yaoxin_list[i].index ;
if(index < dwPacketLength-8)
{
yaoxin_list[i].state = pbyPacket[8+index-1] ;
}
}
SendAllYx() ;
startTm = endTm;
}
}
网友评论