Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Using ISysTimer in an application

To set a timer, an application needs to do the following:

  • Create a signal
  • Create a instance of AEECLSID_SysTimer or AEECLSID_SysTimerUsec
  • Associate the signal with the timer
  • Set the expiration or delay for the timer.

    ISysTimer_SetDelay() can be used to set a timer by specifying a short delay from the current time. ISysTimer_SetExpiry() can used to set a timer by specifying an offset from the time reference returned from ISysTimer_GetTimeRef().

In the following example, the application creates an instance of AEECLSID_SignalCBFactory and then creates a signal by calling ISignalCBFactory_CreateSignal().

   nErr = ISHELL_CreateInstance(pMe->piShell, AEECLSID_SignalCBFactory,
                                 (void**)&piSignalCBFactory);
   if (AEE_SUCCESS == nErr) {
      nErr = ISignalCBFactory_CreateSignal(piSignalCBFactory,
                  c_time_examples_TimerCB, (void*)pMe, 
                  &pMe->piSignal, &piSignalCtl);
   }

The application then creates an instance of AEECLSID_SysTimer, associates the signal with the timer, and sets a delay, as follows:

   // create the timer
   nErr = ISHELL_CreateInstance(pMe->piShell, AEECLSID_SysTimer,
               (void**)&pMe->piSysTimer);

   if (AEE_SUCCESS != nErr) {
	   return FALSE;
   }
   
   nErr = ISysTimer_AssociateSignal(pMe->piSysTimer, pMe->piSignal);
   if (AEE_SUCCESS != nErr) {
	   return FALSE;
   }

   nErr = ISysTimer_SetDelay(pMe->piSysTimer, dwDelay);
   if (AEE_SUCCESS != nErr) {
      return FALSE;
   }