Only the UI-thread can update the UI. Therefore multitasking cannot be used to speed up drawing to the UI.
Try setting DoubleBuffered = true;
in the form after InitializeComponent();
. Sometimes this helps. This setting is often used to reduce flicker.
Are you trying to distribute the controls programmatically? You can use the Anchor
property to have winforms do this automatically for you. There is also a FlowLayoutPanel
and a TableLayoutPanel
. These panels are very helpful for automatic layouts. Even the SplitContainer
can be useful for layouting.
If you are making changes to the UI, you can also try to suspend winforms' layouting. This prevents winforms from doing unnecessary calculations and drawing.
SuspendLayout();
try {
// TODO: Your positioning and sizing logic
} finally {
ResumeLayout();
}
The try-finally ensures that ResumeLayout
runs even in case of an exception, or when you leave the code block with return
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…