Well, about the theory underlying the WHY controllers, it has an affinity like UI.
If you programmed long enough, you should remember the days when forms and rapid application development were not the standard. In those days, just pulling control into shape was rare ... everything was done by the old school.
Now windows have an “old school” way of doing things related to defining WindowProc .
WindowProc is a function that is called to process the application message (there was no notification that I say). This function works in the main thread of the program and is responsible for processing each message that the application receives, including paint and updating the user interface.
Currently, all this is mostly automated, so when creating a form, the code responsible for doing all the work is auto-generated, and you don’t need to worry about it ... but it still exists.
Of course, if the thread responsible for drawing the user interface with all its controls is the main thread, you will see how changing things from another thread can disrupt the application itself with the race conditions and so on. In addition, since UI processing is automatically generated, you cannot just use the synchronization mechanisms that you will use with two standard threads, because you only have access to the code in one thread, and not the main windowproc callback.
In a way, what BeginInvoke will do for you, pass a message to the main thread that says that it kindly handles the delegate in its own context when the time is right, thereby delegating execution to the main thread.
source share