You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently our code uses 1 workbook per timer, which is crazy slow. This is currently declared as "not really an issue" because requiring more than 1 timer is likely rare(?).
However if a work around was desired we could instead:
Cache the workbook
Use the AddTimer() method of below:
PrivateTypeTimercurrentaslongfrequencyaslongidasstringEndTypePrivateTimers()asTimerPrivateConstMAX_TIMEasLong=1000000PrivateConstMIN_TIMEasLong=10SubAddTimer(ByValiMillisecondsaslong,ByValidasstring)ifiMilliseconds>MAX_TIMEtheniMilliseconds=MAX_TIMEifiMilliseconds<MIN_TIMEtheniMilliseconds=MIN_TIMEOnErrorResumeNext:iNext=ubound(Timers)+1:OnErrorGoTo0RedimTimers(0toiNext)WithTimers(iNext)Timers.current=0Timers.frequency=iMillisecondsTimers.id=idEndWithEndSubSubMainLoop()setr=Sheet1.Cells(1,1)WhileTrueForeachtimerinTimerstimer.current=timer.current+1iftimer.currentmodtimer.frequency=0thenr.Value=idtimer.current=0'saves having to deal with overflowsendifnextDoeventsSleep1WendEndSub
OnChange use the id = Target.Value and lookup id in a dictionary to find callback. Also pass id to Tick event.
This can handle multiple timers each added at different times. Unfortunately as new timers are added the whole class slows down, but perhaps this is ok.
The text was updated successfully, but these errors were encountered:
Currently our code uses 1 workbook per timer, which is crazy slow. This is currently declared as "not really an issue" because requiring more than 1 timer is likely rare(?).
However if a work around was desired we could instead:
AddTimer()
method of below:OnChange
use theid = Target.Value
and lookupid
in a dictionary to find callback. Also pass id to Tick event.This can handle multiple timers each added at different times. Unfortunately as new timers are added the whole class slows down, but perhaps this is ok.
The text was updated successfully, but these errors were encountered: