You should never try to use
with WPF, and almost never even with Forms. The accuracy of this timer is prohibitively bad for most applications. There are (at least) three more timer types you can use:
Another option is using a separate thread with loop and
, which I think is the easiest and most straightforward.
Now, as a timer event is not guaranteed to invoke in your UI thread, you generally need to invoke any method using the UI methods/properties on the UI thread, using the Dispatcher. You don't need (and cannot) do it with
, but if you use a separate thread or other timer types, you need to use the dispatcher.
Please see my past answers:
Control.Invoke() vs. Control.BeginInvoke()
Problem with Treeview Scanner And MD5