I need some help fixing a cross-thread exception. I am using Invoke which usually solves this issue, but for some reason it is not wokring:
void paintTimer_Elaps
Invoke
will marshal back the thread that control (the one who's Invoke method is being used) was created on. Make sure the other control was also created on said thread -- that is, make sure one control wasn't created on "the wrong thread" to begin with.
Also, since no target for Invoke
was specified then it will be the this.Invoke
of the containing object/class -- which might not be appropriate.
(Or as Hasan Khan pointed out, consider the WinForms timer... the callback will always run in the thread the timer was created on, in that case.)
Happy coding.