다음을 통해 공유


Starting a Single Timer Event

To start a single timer event, an application must call the timeSetEvent function, specifying the amount of time before the callback occurs, the resolution, the address of the callback function (see TimeProc), and the user data to supply with the callback function. An application can use a function like the following to start a single timer event.

UINT SetTimerCallback(NPSEQ npSeq,  // sequencer data
    UINT msInterval)                // event interval
{ 
    npSeq->wTimerID = timeSetEvent(
        msInterval,                    // delay
        wTimerRes,                     // resolution (global variable)
        OneShotCallback,               // callback function
        (DWORD)npSeq,                  // user data
        TIME_ONESHOT );                // single timer event
    if(! npSeq->wTimerID)
        return ERR_TIMER;
    else
        return ERR_NOERROR;
} 

For an example of the callback function OneShotCallback, see Writing a Timer Callback Function.