Main Site Documentation

Any way to dynamically change the GT.Timer Interval?


#1

I want to dynamically change the timer interval programmatically… such as:

private static int sensorPollingInterval = 5000; //every 5 seconds
private GT.Timer timer = new GT.Timer(sensorPollingInterval);

[do something]

//reset timer to 15 seconds
sensorPollingInterval = 15000;
timer = new new GT.Timer(sensorPollingInterval);

I’ve tried this several ways, but I keep getting a “Exception performing Timer operation” error at run time.


#2

This was helpful, thank you! I have it working now as follows:

private static int sensorPollingInterval = 5000; //every 5 seconds
private GT.Timer timer = new GT.Timer(sensorPollingInterval);

[do something]

//reset timer to 15 seconds
TimeSpan newInterval = new TimeSpan(0, 0, 0, 0, 15000);
timer.Interval = newInterval;