The following example demonstrates
- The use of the System.Windows.Forms.Timer DotNetObject as alternative to the MAXScript rollout Timer control.
- The main advantage of the DotNet version is the ability to call MAXScript functions at given intervals without the need for a rollout.
| |
theTimer = dotNetObject "System.Windows.Forms.Timer" --create a Timer fn printTime = (print localTime) --define a MAXScript function to be called by the Timer. dotnet.addEventHandler theTimer "tick" printTime --add ON TICK event hander to call the function theTimer.interval = 1000 --set the tick interval to 1 second (1000 milliseconds) theTimer.start() --start the Timer --theTimer.stop() --use this method to stop the Timer. |
RESULT: |
dotNetObject:System.Windows.Forms.Timer printTime() OK 1000 undefined "10/20/2006 1:11:28 PM" "10/20/2006 1:11:29 PM" "10/20/2006 1:11:30 PM" "10/20/2006 1:11:31 PM" ... |