View Single Post
07/20/22, 03:50 AM   #13
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Alright, thanks for the details, very appreciated!
I think I always used an unregister before registering a new update task, so it should work the same for my code
Originally Posted by ZOS_DanBatson View Post
It will do the first one. Example:

Register updaterCallbackFunction() to "UpdateInv1" with an interval of 1000
After 200 ms, Register updaterCallbackFunction() to "UpdateInv1" with an interval of 1000. (Original registration is now gone.)
After 1000 more ms (1200 ms total elapsed), updaterCallbackFunction() will get called for the first time.

Calling RegisterForUpdate again with the same identifier will replace everything and reset the timer.

You're incorrect though about the "in the past" behavior. In the past, the behavior used to be this:

Register updaterCallbackFunction() to "UpdateInv1" with an interval of 1000
After 200 ms, try to register updaterCallbackFunction() to "UpdateInv1" with an interval of 1000. This request just gets dropped on the ground completely, because "UpdateInv1" is already registered.
After 800 more ms (1000 ms total elapsed), updaterCallbackFunction() will get called for the first time.

In the past, you couldn't replace the function or reset the clock. Again, trying to register again would previously literally just abort because something is already registered. Now, it's a replace and reset.

In the past, if you wanted to replace the function or change/reset the interval, you had to manually UnregisterForUpdate the identifier first.
  Reply With Quote