+ 2
When to use which timer ?
I need a timer in wpf application. I found three timers, but do not know which one to use System.Threading.Timer System.Timers.Timer System.Windows.Threading.DispatcherTimer What is the difference between these timers? When do you prefer a certain timer ? Which one do you use ?
5 Answers
+ 11
Would you mind to elaborate on the usage of the timer in your application so we can help you to narrow down the choice?
There are always more than one way to solve a problem in programming so getting into the specific definitely help to make better decision. đ
+ 8
Sorry for overlooking the post. It seems that the recommended way to do it is using
System.Threading.Timer
as it runs on a different thread and don't need to tie with the UI.
I believe you can find good explanation on MSDN and some StackOverflow posts regarding the difference. đ
+ 2
Up
Maybe my question got lost in the stack, I am still looking for the answer though.
Can you answer my question or do I need to explain more ?
0
Sure.
I would like to know in which case I should use which one in general. They a look a like for me at the moment.
To be specific.
I have a task in a c# / wpf program, which needs to run once a day.
It is a copying task so it has nothing to do with UI.
Currently
I have a timer ( System.Timers.Timer) , which has a interval of 3600 000 ms (1 Hour).
In the Elapsed_event, I test if DataTime.Now.Hour == 5
If it is 5, I perform the copying task.
But I am not sure this is the best way and best timer to do this.
0
Thanks.