Picking up where we left off, the previous article introduced the Dispatcher in WPF. Because there were so many concepts, it may not have been easy to follow. This article continues the discussion, and I hope we can finally make threads and the Dispatcher clear.
Where Do We Start?
As usual, before diving into a problem we look for an entry point, and I hope that entry point will be easy for readers to understand.
Create a new Win32 window program with the following code:
int WINAPI _tWinMain ( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPTSTR lpCmdLine , int nCmdShow ) { RegisterWindowClass ( hInstance ); // 1 HWND hWnd = CreateWindow ( szWindowClass , szTitle , WS_OVERLAPPEDWINDOW , // 2 CW_USEDEFAULT , 0 , CW_USEDEFAULT , 0 , NULL , NULL , hInstance , NULL ); ShowWindow ( hWnd , nCmdShow ); MSG msg ; // 3 while ( GetMessage ( & msg , NULL , 0 , 0 )) { TranslateMessage ( & msg ); DispatchMessage ( & msg ); } return ( int ) msg .…