Jonathan Beerhalter
Jonathan Beerhalter

Reputation: 7407

Why does WinForms fail to paint on occasion?

I'm responsible for supporting a winforms application, and occasionally, the app will not paint correctly. Sometimes numeric updowns will just be grey(the default control color), yet they'll still work. Other times certain buttons won't paint correctly.

We haven't written any custom painting code, no GDI+, nada. Therefore, AFAIK, everything should be handled by Windows.

The trouble is, tickets will come in with photos of parts of the app that haven't rendered properly, and I don't know how to even begin debugging them, because I have no idea what might be wrong.

So, the question is, why does WinForms fail to paint sometimes? Are there certain things I should be looking towards?

Upvotes: 0

Views: 283

Answers (2)

Chad La Guardia
Chad La Guardia

Reputation: 5174

In addition to what Erno has said, I would add that I had some weird issues when one of the winforms apps I was working on used a transparency color for some images that was common in my controls. If your app is using any images and you've set a transparency color that your buttons or controls are using, weird things happen.

Upvotes: 0

Emond
Emond

Reputation: 50712

In Winforms the UI and the logic are normally executed on the SAME thread.

So when you block the UI thread by querying a database, reading a file or whatever takes more time than can go unnoticed the UI will not be updated for that time.

Another reason can be that the thread simply doesn't get time to execute because an other thread has a higher priority and gets time on the CPU.

Upvotes: 4

Related Questions