Question

I have setup DispatchTimer correctly to fire every second-

OneSecondChecker = new DispatcherTimer();
OneSecondChecker.Tick += new EventHandler(OneSecondChecker_Tick);
OneSecondChecker.Interval = new TimeSpan(0, 0, 1);                 
OneSecondChecker.Start();

Problem: And it fires correctly for a certain period of time after which it just stops firing.

Additional Information: Now you might ask what does it do? There is a class level (static) boolean variable that is set to true if the method OneSecondChecker_Tick() is running, and then is set to false if it is not, so that we don't have two instances of this method running at the same time even if it is set to fire every second. It is an application requirement to make sure OneSecondChecker_Tick() runs without any delay. I am also not trying to run in an infinite loop. There is a second check to see if a table value is updated to before OneSecondChecker_Tick() runs. It is that table value that "sort of" informs OneSecondChecker_Tick() to run. That table value is updated by another application.

Within the method itself I do have a call to run threads in parallel using TPL. I don't know if it has anything to do with it.

EDIT I still haven't been able to figure this one out. It might be that the application is frozen. The task manager does not say that though. Is it possible to tell if the application is not responding from somewhere other than the task manager?

Was it helpful?

Solution

The problem is not with DispatchTimer. It wasn't even with TPL. The problem was elsewehre in the code running in an infinite loop and causing stack overflow - after which it stopped firing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top