First, the Windows program message mechanism
1. The Windows Program message mechanism is implemented using Message Queuing.
(1), the UI thread is the main thread that manages the entire form and the running of the child controls.
(2), all messages on a form are the primary source of Message Queuing.
(3), PeekMessage, getmessage are used to view application message queues, and messages are dispatched when messages are in the queue.
GetMessage is returned only if there is a message in the message queue, no message getmessage in the queue waits until the next message appears. During the waiting period, the application cannot execute any instructions. That is, when the queue is empty, the getmessage is blocked, causing the while loop to stop, preventing a program from draining the CPU.
Regardless of whether or not the application message queue has a message, the PeekMessage function returns immediately, allowing the program to continue executing the following statement (no message executes other instructions, the message is generally dispatched, and other instructions are executed).
2, ISynchronizeInvoke attribute invokerequired, is used to determine whether the Windows Forms thread and the current caller thread are the same. If so, access the GUI control directly; otherwise, use Invoke or BeginInvoke to access the UI control.
The control class invoke and BeginInvoke are implemented through the Windows Messaging Mechanism (PostMessage).
Second, reference materials:
(1),peekmessage&getmessage
Http://www.cnblogs.com/faceang/archive/2010/05/25/1743757.html
(2),peekmessage use method
Http://www.cnblogs.com/likebeta/archive/2012/03/28/2421580.html
(3),Invoke and BeginInvoke
Http://www.cnblogs.com/worldreason/archive/2008/06/09/1216127.html
"C #" Windows program message mechanism