Differences between winform-invalidate, update, and refresh

Source: Internet
Author: User

Control. Refresh-does an control. invalidate followed by control. Update.
Refresh: forces the control to invalidate its Workspace and immediately redraws itself and any child control. = Invalidate + update

Control. invalidate-invalidates a specific region of the control (defaults to entire client area) and causes a paint message to be sent to the control. invalidate marks the control (region, or rect) as in need of repainting, but doesn' t immediately repaint (the repaint is triggered when everything else has been taken care of and the app becomes idle ).
Invalidate: invalidates a specific region of the control (you can set the region by yourself to improve performance) and sends a draw message to the control.
Mark the control as re-painted, but do not immediately refresh and re-paint when the system is idle.

Control. update-causes the paint event to occur immediately (Windows will normally wait until there are no other messages for the window to process, before raising the paint event ). update causes the control to immediately repaint if any portions have been invalidated.
Update: Re-paint the invalid area in the workspace of the control and call the paint event immediately. If an invalid region exists, update will immediately trigger re-painting.

The paint event of course is where all the drawing of your form occurs. note there is only one pending paint event, if you call invalidate 3 times, you will still only receive one paint event.
Paint: ubiquitous. If you call invalidate three times, the system will trigger only one painting event.

 

Most of the time invalidate is sufficient, and advisable as you can do a bunch of invalidations (either explicit or implicit) and then let the control repaint itself when the app is idle. it is advisable to use update or refresh when you want the control to immediately repaint because the app will not be idle for a user-noticable period of time.

Most of the time, invalidate is enough. We recommend that you use invalidate when the system needs to refresh a large amount of data in a centralized manner, because the system will only refresh once, improving the system performance. We recommend that you use the refresh method if you want to perform the refresh operation immediately.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.