Timers are generally bad. One timer,
System.Windows.Forms.Timer
is the easiest but provide unacceptable accuracy (there are rare cases when that's all right, but not like yours), other two are better, but there is a lot of bothering with them. Did you ever try to account for the situation when a new timer event is invoked when your timer event handler is still executing?
Threads is much more straightforward way, because the logic is linear. You need to create a separate thread with a loop with some delay using
Thread.Sleep
.
First of all, I recommend using a thread wrapper to solve the problem of passing parameters to it. Please see my past solutions:
How to pass ref parameter to the thread[
^],
change paramters of thread (producer) after it started[
^].
Now, you need to update your UI in each cycle. On problem is: you cannot call anything related to UI from non-UI thread. Instead, you need to use the method
Invoke
or
BeginInvoke
of
System.Windows.Threading.Dispatcher
(for both Forms or WPF) or
System.Windows.Forms.Control
(Forms only).
[EDIT]
By the way, two "normal" timers (other than
System.Windows.Forms.Timer
) will need UI thread invocation described above anyway, so you cannot win with a timer by not doing the invocation.
[END EDIT]
You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA