控制某个不间断调用函数的调用频率

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");

}

 

posted on 2013-02-21 18:26  All IN  阅读(221)  评论(0)    收藏  举报

导航