void LASARRAY_UnstableTestAfter5Minutes()
{
static time_t Old_time = 0;
time_t nt;
CString strSQL;
time(&nt);
nt -= Old_time;
if((nt/60) >= 1){//此處的1表示間隔時間
time(&Old_time);
time(&nt);
nt -= 1200;
strSQL.Format("到達指定時間所執行的部分");
cout << strSQL << endl;
}
else {
cout << "未到達指定時間所執行的部分" << endl;
}
}
int main(int argc, char **argv)
{
while(1)
{
LASARRAY_UnstableTestAfter5Minutes();
Sleep(1000);
}
system("pause");
return 0;
}
第一次執行的時候是到達指定時間間隔的,之後每次到達指定時間間隔才執行