View Single Post
07/19/22, 04:19 PM   #10
ZOS_DanBatson
ZOS Staff!
 
ZOS_DanBatson's Avatar
Yes this person is from ZeniMax!
Join Date: Jul 2015
Posts: 181
Originally Posted by Baertram View Post
With this changes done, maybe I totally missunderstand your post, but what happens differently now?

If I got a function that was using RegisterForUpdate to e.g. register an inventory refresh via updaterCallbackFunction() after 50ms with unique identifer "UpdateInv1".
And after 10ms another RegisterForUpdate for the same inventory refresh using same unique update identifier "UpdateInv1" with 50ms comes in, without unregistering the first updater:

Will it overwrite the updater "UpdateInv1" and reset the timer to 50ms again, so that the registered updaterCallbackFunction() is called 50ms after the 2nd RegisterForUpdate was done?
Or will the 1st registered "UpdateInv1" call the updaterCallbackFunction() after the 40ms left have passed then, and the 2nd registered "UpdateInv1" will fire after 50ms too?


In the past "UpdateInv1" was overwritten and the timer was reset to 50ms. The 1st registered "UpdateInv1" was never triggered, and the 2nd "UpdateInv1" was triggering updaterCallbackFunction() after 50ms then.
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