none
C++ 定时器 之后延迟一段时间 再开一定时器 RRS feed

答案

  • HANDLE timerQueue = CreateTimerQueue();

    HANDLE timer1 = NULL;

    HANDLE timer2 = NULL;

    CreateTimerQueueTimer(&timer1, timerQueue, Timer1Callback,  timerQueue, 0, 2000, WT_EXECUTEDEFAULT);

    VOID CALLBACK Timer1Callback(PVOID lpParam, BOOLEAN timerOrWaitFired)

    {

    HANDLE timerQueue = (HANDLE)lpParam;

    int n = 3000; //你需要延迟执行的时间间隔

    CreateTimerQueueTimer(&timer2, timerQueue, Timer2Callback,  timerQueue, n, 2000, WT_EXECUTEDEFAULT);

    }

    VOID CALLBACK Timer2Callback(PVOID lpParam, BOOLEAN timerOrWaitFired)

    {

    }

    2013年12月4日 1:21
  • HANDLE timerQueue = CreateTimerQueue();
    HANDLE timer1 = NULL, timer2 = NULL;

    ::CreateTimerQueueTimer(&timer1, timerQueue, TimerCallback1, timerQueue, 0, 3000, WT_EXECUTEDEFAULT);

    VOID CALLBACK TimerCallback1(PVOID lpParam, BOOLEAN timerOrWaitFired)
    {
     HANDLE timerQueue = (HANDLE)lpParam;
     int dueTime = 3000;   // 你需要延迟执行的时间

     ::CreateTimerQueueTimer(&timer2, timerQueue, TimerCallback2, timerQueue, dueTime, 3000, WT_EXECUTEDEFAULT);
    }

    VOID CALLBACK TimerCallback2(PVOID lpParam, BOOLEAN timerOrWaitFired)
    {
    }

    2013年12月4日 1:27

全部回复

  • HANDLE timerQueue = CreateTimerQueue();

    HANDLE timer1 = NULL;

    HANDLE timer2 = NULL;

    CreateTimerQueueTimer(&timer1, timerQueue, Timer1Callback,  timerQueue, 0, 2000, WT_EXECUTEDEFAULT);

    VOID CALLBACK Timer1Callback(PVOID lpParam, BOOLEAN timerOrWaitFired)

    {

    HANDLE timerQueue = (HANDLE)lpParam;

    int n = 3000; //你需要延迟执行的时间间隔

    CreateTimerQueueTimer(&timer2, timerQueue, Timer2Callback,  timerQueue, n, 2000, WT_EXECUTEDEFAULT);

    }

    VOID CALLBACK Timer2Callback(PVOID lpParam, BOOLEAN timerOrWaitFired)

    {

    }

    2013年12月4日 1:21
  • HANDLE timerQueue = CreateTimerQueue();
    HANDLE timer1 = NULL, timer2 = NULL;

    ::CreateTimerQueueTimer(&timer1, timerQueue, TimerCallback1, timerQueue, 0, 3000, WT_EXECUTEDEFAULT);

    VOID CALLBACK TimerCallback1(PVOID lpParam, BOOLEAN timerOrWaitFired)
    {
     HANDLE timerQueue = (HANDLE)lpParam;
     int dueTime = 3000;   // 你需要延迟执行的时间

     ::CreateTimerQueueTimer(&timer2, timerQueue, TimerCallback2, timerQueue, dueTime, 3000, WT_EXECUTEDEFAULT);
    }

    VOID CALLBACK TimerCallback2(PVOID lpParam, BOOLEAN timerOrWaitFired)
    {
    }

    2013年12月4日 1:27