开发者

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, ev开发者_如何转开发erything 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜