I want to use C# Timer in DLL application
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
TimeSpan interval = TimeSpan.FromMinutes(5);
dispatcherTimer.Interval = interval;
dispatcherTimer.Start();
but the problem is that is never triggered. Method dispatcherTimer_Tick
is never triggered even if time is 5 minutes. There is no error nothing.
Any idea why? I am using .net 4.0
Use
System.Timers.Timer
instead,This works in all the application type, whether app is web, console, WPF etc and you do not need to worry about the environment or application it is been used.