Missing Messages
FeaturedHi
I'm currently profiling my application and I have a question concerning
SendMessage / DispatchMessage.
From the communication thread we have 165'238 OnPropertyChange and the
same hit count for Dapfor.Net.Internal.SafeNativeMethods.SendMessage().
On the GUI thread we only have a hit count of 134'213 for
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW() resulting in
130'958 Dapfor.NetUi.Grid.OnPaint events.
Actually I expected to have at least 165'238 hits of DispatchMessageW and
now I'm not sure if the application is missing 30'000 updates. Or is there
an easy explanation for this?
Thanks for your support.
Best Regards
Ax
GUIThread.jpg
CommThread.jpg
-
Hi,
You are measuring different things. On the communication side, you call the SendMessage method. It should be understood that this method doesn’t send messages through the Windows MessageQueue but sends them directly to the graphical thread. The SendMessage call is blocking until the processing of the message (as opposed to PostMessage). From the GUI side, the graphical thread calls the Control.Invalidate (Rectangle). This method does not directly repaint the surface, but informs the system that need to be redrawn later. It should be noted that Invalidate() can be called multiple times. At some moment Windows decides it is necessary to redraw the surface and generates a WM_PAINT message, which you see in the DispatchMessage. Upon receiving this message the grid gets the region, which contains a collection of Rectangle, specified in Invalidate.
Accordingly, the number of calls of the Invalidate can (and should) be greater than the amount WM_PAINT messages. The greater the CPU load, the greater must be the difference between the number of calls.
As a consequence, in the case of high volatility of markets the method Invalidate() can be called multiple times for a single cell. At the same time, the cell will be redrawn only once with the latest data. It should also be said that in Windows the minimum time between two neighboring WM_PAINT not be less than 15 ms. And the higher the CPU load, the less often it is coming.
Best regards,
Dapfor
0
Please sign in to leave a comment.
Comments
1 comment