Microsoft KB Archive/312406

= PRB: KillTimer Function Kills the Timer Created by Another Application =

Article ID: 312406

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows 95
 * Microsoft Windows 98 Standard Edition
 * Microsoft Windows 98 Second Edition

-



This article was previously published under Q312406



SYMPTOMS
When two applications create timers by calling the SetTimer function, and the window handle is set to NULL, one application may kill the timer created by the other application.

This behavior can occur under the following scenario:
 * 1) Application A allocates a timer (id=A), and then kills it.
 * 2) Application B allocates a timer (id=A is reused).
 * 3) Application A kills this timer again.
 * 4) Application A allocates a timer (id=A is reused), and then kills it.
 * 5) Application B attempts to kill the timer (id=A), but this operation fails.



CAUSE
This behavior can occur because timers are allocated from a global resource. When the KillTimer function is called with a timer ID, it destroys any timer that it is directed to. Furthermore, SetTimer may reuse timer IDs when the window handle parameter is set to NULL. In this case -- where multiple applications create and destroy timers against the NULL window, and one application destroys a timer twice -- the possibility of a collision exists.



RESOLUTION
To resolve this issue, modify your code so that it always uses a non-NULL window handle when it creates timers.



STATUS
This behavior is by design.

Keywords: kbprb KB312406

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.