控制某个不间断调用函数的调用频率
View Code
#include <Windows.h> #include <stdio.h> void Foo(); int main() { while(1) { Foo(); } } void Foo() { static DWORD dwStartT = 0; DWORD dwCurT = GetTickCount(); if(dwCurT - dwStartT < 5000) { return ; } dwStartT = dwCurT; printf("foo call \n"); }

浙公网安备 33010602011771号