holtavolt
holtavolt

Reputation: 4468

Winform Control.Refresh - guaranteed synchronous?

Invoking the WinForms Control.Refresh method is described in MSDN as:

Forces the control to invalidate its client area and immediately redraw itself and any child controls.

I am debugging an intermittent issue that seems to occur when the attached display is switching scanout signals (effectively changing resolution), in which a Control.Refresh appears to not be generating the expected Control.OnPaint call. I am instrumenting the application to get more information, however I'm curious if this could actually be the runtime deciding not to invoke the OnPaint because it detects the display is momentarily blanked out.

This seems unlikely to me, and I expect I'll find some other smoking gun, but I'm posting on the off-chance somebody else has seen this in the wild, and has some recommendations for handling this.

Upvotes: 1

Views: 862

Answers (1)

LarsTech
LarsTech

Reputation: 81675

No, it's not guaranteed. If the control does not have a screen to draw on, it won't fire the paint message.

But once the control is on the screen again, the paint message should fire again.

Are you trying to paint debug information? If the control isn't on the screen, what are you expecting to happen when you call refresh?

Upvotes: 1

Related Questions