It's a
bad idea to use timers for communication. You could use stream much more reliably and easier. It even less understandable that you are already using a thread. You did not explain what kind of timer do you use and why.
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). The same goes for the timer handler (
don't use the timer), unless this is the timer
System.Windows.Forms.Timer
. But this type of timer is too bad for most purposes except some we don't need to discuss here.
Don't use any timers at all, anyway.
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