I understand that an event handler executes on whatever thread that invoked the event. I further understand the need to update form controls only from the thread that created the controls. I am assuming that the UI thread is the one that created the form for the purpose of this question.
If the event is the result of a posted message, such as a paint message, isn’t the handler then decoupled from the originating thread? If that is true, then any thread could invoke invalidation operations and the resulting paint would always occur on the UI thread since it is the one handling form messages.
This is how it maps out in my head at near 2:00 AM with a long-empty snack bowl by my side. Please clarify and correct so I can have a proper understanding of the mechanisms at work.
MSDN:
Calling the Invalidate method does not force a synchronous paint; to force a synchronous paint, call the Update method after calling the Invalidate method.
So, Invalidate can be called from any thread, and Update only from UI thread. In any case, to be 100% sure that you don’t use invalid cross-thread calls, set Control::CheckForIllegalCrossThreadCalls property to true in the beginning of the program. This causes any invalid call to fail immediately, you don’t need to guess.