I’ve noticed that when “giving focus” back to your main thread, when invoking from another thread, you can either invoke “this” or the control that you would like to, well invoke. I’ve noticed this doesn’t matter when giving control back, so can anyone explain why I would invoke a control over the main thread? Does it matter, or is the main thread being implicitly invoked?
Would,
this.Invoke(InvokedMethod,args)
be different from
button1.Invoke(InvokedMethod,args)
When button1 is on my main form.
Invoking on a control uses the control’s handle to determine which thread is the control’s UI thread, and then uses that thread to execute. It is possible to have multiple UI threads (a UI thread is any thread running a message loop), or it is possible for a control to have a handle to a non-UI thread (if progamatically creating controls incorrectly). Usually, there is no difference between invoking on the main form or a control, but it may matter in certain circumstances.