开发者

How can I measure how busy the UI thread is using Winforms

I have a busy WinForms UI that has data coming in from multiple sources. Since only the UI thread can update the controls on the UI, these threads bringing in new data update intermediate data structures, which the UI thread reads and then uses to update the controls on the form.

To keep from having concurrency issues, we lock the data structures when reading and writing from them.

Everything in the application works fine, but the UI can get pretty laggy and slow, especially when we're getting quite a bit of data coming in quickly. I think this is occuring because the UI is spending quite a bit of time waiting to acquire locks.

I know that I can use the ProcessThread.TotalProcessorTime to measure thread utilization, but the trouble is, that doesn't include time waiting at locks. So it's a nice measure of how busy the UI thread is in a single threaded world, but once you have locking involved, the numbers get skewed downward the more time the UI thread spends waitin开发者_开发技巧g to acquire locks. And it's precisely those times, waiting for locks, when the UI will be unresponsive.

I suppose, in a nutshell, this boils to down measuring contention in a Winforms app.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜