Shoutbox

Timer bug ? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: WLM Plus! Bug Reports (/forumdisplay.php?fid=7)
+----- Thread: Timer bug ? (/showthread.php?tid=63615)

Timer bug ? by OcuS on 07-19-2006 at 04:22 PM

Here is the code to Add Timers :

code:
function OnEvent_Initialize(MessengerStart) {
        AddTimers(1);
}

function AddTimers(Mult) {
        var Elapse, TimerId;
        for (var i = 1 ; i <= 10 ; i++) {
                Elapse = 100 + (i * Mult);
                TimerId = 'Timer_Mult:' + Mult + '_' + i + '_Elapse:' + Elapse;
                MsgPlus.AddTimer(TimerId, Elapse);
                Debug.Trace('<-- Timer added : ' + TimerId);
        }
}

function OnEvent_Timer(TimerId) {
        Debug.Trace('--> Timer catched : ' + TimerId);
}



Tested on my computer, with AddTimers() argument lower than 20 (in most cases) (works for > 20).
This should give (notice the catch order) :
code:
<-- Timer added : Timer_Mult:1_1_Elapse:101
<-- Timer added : Timer_Mult:1_2_Elapse:102
<-- Timer added : Timer_Mult:1_3_Elapse:103
<-- Timer added : Timer_Mult:1_4_Elapse:104
<-- Timer added : Timer_Mult:1_5_Elapse:105
<-- Timer added : Timer_Mult:1_6_Elapse:106
<-- Timer added : Timer_Mult:1_7_Elapse:107
<-- Timer added : Timer_Mult:1_8_Elapse:108
<-- Timer added : Timer_Mult:1_9_Elapse:109
<-- Timer added : Timer_Mult:1_10_Elapse:110
--> Timer catched : Timer_Mult:1_1_Elapse:101
--> Timer catched : Timer_Mult:1_2_Elapse:102
--> Timer catched : Timer_Mult:1_3_Elapse:103
--> Timer catched : Timer_Mult:1_4_Elapse:104
--> Timer catched : Timer_Mult:1_5_Elapse:105
--> Timer catched : Timer_Mult:1_6_Elapse:106
--> Timer catched : Timer_Mult:1_7_Elapse:107
--> Timer catched : Timer_Mult:1_8_Elapse:108
--> Timer catched : Timer_Mult:1_9_Elapse:109
--> Timer catched : Timer_Mult:1_10_Elapse:110


but it give :
code:
<-- Timer added : Timer_Mult:1_1_Elapse:101
<-- Timer added : Timer_Mult:1_2_Elapse:102
<-- Timer added : Timer_Mult:1_3_Elapse:103
<-- Timer added : Timer_Mult:1_4_Elapse:104
<-- Timer added : Timer_Mult:1_5_Elapse:105
<-- Timer added : Timer_Mult:1_6_Elapse:106
<-- Timer added : Timer_Mult:1_7_Elapse:107
<-- Timer added : Timer_Mult:1_8_Elapse:108
<-- Timer added : Timer_Mult:1_9_Elapse:109
<-- Timer added : Timer_Mult:1_10_Elapse:110
--> Timer catched : Timer_Mult:1_9_Elapse:109
--> Timer catched : Timer_Mult:1_8_Elapse:108
--> Timer catched : Timer_Mult:1_7_Elapse:107
--> Timer catched : Timer_Mult:1_6_Elapse:106
--> Timer catched : Timer_Mult:1_5_Elapse:105
--> Timer catched : Timer_Mult:1_4_Elapse:104
--> Timer catched : Timer_Mult:1_3_Elapse:103
--> Timer catched : Timer_Mult:1_2_Elapse:102
--> Timer catched : Timer_Mult:1_1_Elapse:101
--> Timer catched : Timer_Mult:1_10_Elapse:110


They appeared in a random order...
RE: Timer bug ? by Patchou on 07-19-2006 at 06:56 PM

There is no guarented order for timers. The resolution is about 10ms so there's bound to be problems like the one you point out. You jsut can't expect two timers created one after the other with the same value to be fired in order, they have the same timeout value after all :).