如何有效地渲染UI [英] How to Render UI Efficiently

查看:107
本文介绍了如何有效地渲染UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在通过一个事件处理程序接收实时股票市场数据,该事件处理程序每​​秒发出约10-20 msgs ...我的责任是使用从蒸汽处理程序接收到的数据流来呈现UI .我当前将流传递到队列,并发出信号通知工作线程获取结果并进行一些非常轻量级的处理,然后将这些结果传递给工作线程触发的eventHandler.然后,我调用winForm控件以从线程的处理程序中呈现数据...

我的应用程序似乎在市场交易时段没有跟上进度...有人可以给我一些有关如何有效呈现UI控件的建议/指针吗?

预先感谢,
-da

I''m currently receiving real-time stock market data via an eventHandler that''s firing about 10-20 msgs per/millisecond...my responsibility is to render the UI with data stream received from from the steam handler. I''m current passing the stream to a queue with signals a worker thread to get the results and do some VERY light weight processing and pass those result off to an eventHandler that worker thread fires. I then invoke the winForm controls to render the data from my thread''s handler...

my app seems not be keeping up during peek market hours...can someone please give me some advice/pointers on how to render UI controls efficiently?

thanks in advance,
-da

推荐答案

要检查的一件事是,线程之间没有太多的交互作用,这取决于应用程序的编码方式.根据经验,我知道在使用后台工作程序时,如果我们过多地报告该过程,UI线程将变得非常忙碌,并且应用程序无法冻结.

因此,一个建议是确保您不会过于频繁地更新UI(例如,根据图表的复杂程度,每秒更新的时间不得少于几次).

降低显示的复杂性,或者在应用程序较晚的情况下跳过某些帧,或者限制刷新率.

根据用于显示数据的方式,处理大数据的速度可能会非常慢.对于非常大的数据或实时数据,您必须花时间评估一些替代方案.

您可能需要对数据进行预处理,以通过平均或类似方法减少点数.

有些组件比其他组件更好.另外WPF可能更快...您应该尝试...
One thing to check is that there is not too much interaction between threads depending on how your application is coded. By experience, I know that when using a background worker, if we report the process way too much often, the UI thread will get too busy and apppears to freeze.

Thus one suggestion is to ensure you won''t update your UI too often (say mo than a few time per seconds depending on the complexity of the chart).

Reduce display complexity or skip some frames if the applications is late or limit the refreshing rate,

Depending on what you use to display your data, it can be very slow for large data. For very large data or real time, you have to take time to evaluate some alternative.

You might have to preprocess the data to reduce the number of points by averaging or something similar.

Some components are way better that others. Also WPF might be faster... You should try...


这篇关于如何有效地渲染UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆