views:

62

answers:

4

Hi, I created a Timer

private static AutoResetEvent autoEvent;
private static Timer stateTimer;
public static void Start()
{
    autoEvent = new AutoResetEvent(false);
    TimerCallback timerDelegate = new TimerCallback(SomeClass.TimerLoad);
    stateTimer = new Timer(timerDelegate, autoEvent, 1000, 3 * 60 * 60 * 1000);
}

from other procedure I change timer:

stateTimer.Change(0, 5 * 60 * 1000);

now, I need to know what is the interval, is there any appropiate instruction for that ?

+1  A: 

What about the Interval property of Timer ?

Timores
this is not Windows.Form Timeris a System.Threading.Timerit does not have Interval property
Alexei.Ozon
+3  A: 

I have not found a way to do this yet. When faced with the same problem, I resorted to storing the interval whenever I changed my timer.

The "good" way might be to inherit the Timer class and add the property there...

Jens
+1 : Subclassing seems a good idea, nicer than storing a local variable which was my inital thought.
Ian
I did this same way
Alexei.Ozon
+2  A: 

Aren't you setting the interval in your Change method call, when you specify 5 * 60 * 1000. So, your interval is 300000.

Ardman
+1  A: 

Use System.Timers.Timer instead, that has an interval property.

http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx

JonB