I’ve got a little problem using WPF Dispatcher Timer. On each timer tick my application freezes for a moment (until timer tick method finishes). This is my code:
private DispatcherTimer _Timer = new DispatcherTimer();
_Timer.Tick += new EventHandler(_DoLoop);
_Timer.Interval = TimeSpan.FromMilliseconds(1500);
_Timer.Start();
Is there any way to avoid this and have my application run smoothly?
This is expected. your _DoLoop is executed on the same thread as UI.
from DispatcherTimer Class MSDN
If you need to execute time consuming computations run it on another thread to keep UI responsive.