Düzenle

Aracılığıyla paylaş


Creating a Timer Event with __TimerInstruction

You create a timer event by creating an instance of classes derived from the __TimerInstruction class in any WMI namespace. WMI then generates the timer event at the appropriate time. If you miss a timer event due to computer downtime, WMI notifies you about the missed event. WMI supports timer events for backward compatibility and for scenarios where you must know how many events you have missed since the last delivered event. For most timer events, however, you should create an event filter for Win32_LocalTime or Win32_UTCTime. For more information, see Creating a Timer Event with Win32_LocalTime or Win32_UTCTime.

The following procedure describes how to create and receive a timer event with __TimerInstruction.

To create and receive a timer event with __TimerInstruction

  1. Create an instance of the __AbsoluteTimerInstruction or __IntervalTimerInstruction classes.

    The __AbsoluteTimerInstruction and __IntervalTimerInstruction classes are derived from the __TimerInstruction class, which contains a unique developer-assigned string that identifies the type of timer event. The __TimerInstruction class also contains a value that specifies whether WMI should send a belated notification if the timer event occurs when WMI is unavailable.

    Use __AbsoluteTimerInstruction to send absolute timer events, which occur on a specific date at a specific time. Use __IntervalTimerInstruction to send interval timer events, which occur on a regular basis.

  2. Set your application to receive a __TimerEvent instance.

    To generate an event, WMI creates an instance of the __TimerEvent class and forwards the instance to your consumer. The __TimerEvent instance contains the timer instruction identifier from the consumer. The instance also contains a value that specifies how many times WMI should send the timer event notification during any interval when WMI cannot reach the consumer.