Delaying until a specific time

To delay a thread until a specific time, you use the TClock::DelayUntil function. To call DelayUntil, a thread must have a time instance that specifies the time to delay until, and a clock to delay on.

To delay the calling thread until 1 hour after the system boots:

  1. Instantiate THours and TSystemClock.
    Because you want to specify a time based on the boot time, you use the system clock--the clock time of the system clock is set to zero when the system finishes booting.
  2. Call DelayUntil on the system clock instance with the delay time, one hour.
    The delay returns when the current time on the system clock is greater than or equal to 1 hour--1 hour after the boot of the system.
      THours      delayTime(1);
      TSystemClock realTimeClock;
      realTimeClock.DelayUntil(delayTime);

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker