Notifications
Clear all
[Closed] Dotnet timer differences
Oct 27, 2014 12:34 am
ftm = dotnetobject “System.Windows.Forms.Timer”
ttm = dotnetobject “System.Timers.Timer”
ntm = dotnetobject “Timer”
what is the difference?
may there appear conflicts if some are used simultaneously in different scripts? If yes, then how to avoid?
6 Replies
1 Reply
Oct 27, 2014 12:34 am
“System.Windows.Forms.Timer” is the same class as “Timer”. Maxscript automatically searches inside “System.Windows.Forms”.
“System.Timers.Timer” is a different beast, and so is “System.Threading.Timer”.
Read about the differences:
http://msdn.microsoft.com/en-us/magazine/cc164015.aspx
Oct 27, 2014 12:34 am
(
local theTimer -- If its global then it's working from startup
fn myfn =
(
print "inside function"
)
print "outside function"
theTimer = dotNetObject "System.Windows.Forms.Timer"
theTimer.interval = 200
theTimer.start()
fn onTick s a =
(
myfn()
theTimer.Stop()
)
dotnet.addEventHandler theTimer "tick" onTick
)
I’ve got a very strange situation. Why the timer should be global to work from startup?
Oct 27, 2014 12:34 am
It doesn’t have to be global, but in order to keep it from being garbage collected, you must:
- keep a reference to it somewhere, like a struct, rollout, etc.
- or use dotnet.SetLifetimeControl #dotnet