views:

138

answers:

2

On my application I have a timer that checks for configuration updates from the server in a few minutes intervals.

The configuration retrieval is a pretty time consuming process, so I want to force the timer's "Tick" event, but I cannot just call the timer_tick(bla,bla,bla) because it will execute synchronously.

Is there a simple way to force the timer to "Tick" (without creating a new thread)? The behavior should "reset" the time-left of the timer (so, if originally the timer was set to 2 minutes interval and 1 minute already past - after forcing the "Tick" - the timer will start counting 2 minutes again)

+1  A: 

change it's timeout value.

thelost
Thanks dude... I created a simple application to check the affects of changing the timeout while the timer is running and it works great.What I did was changing the timer's interval to 1 (minimum possible), Thread.Sleep(1), and reseting the interval to its original value... worked like a charm
Nissim
A: 

Within your consuming process your first step is just to disable the timer and the last step is to enable it again.

Maybe you just put this dis- and enable just before and after calling your long running process like this:

timer.Enabled = false;
LongRunningSyncProcess();
timer.Enabled = true;
Oliver
LongRunningSyncProcess() will run synchronouly - exatcly what I didn't want
Nissim