简体   繁体   English

在 WindowsFormsHost 控件中更新 WinForms Chart 时,WPF WebBrowser 不更新

[英]WPF WebBrowser not updating when WinForms Chart is updated in WindowsFormsHost control

I have a WPF application with two windows.我有一个带有两个窗口的 WPF 应用程序。 One window contains a WebBrowser control.一个窗口包含一个 WebBrowser 控件。 The other window contains a WindowsFormsHost which hosts a WinForms Chart control for drawing a line chart.另一个窗口包含一个 WindowsFormsHost,它承载一个用于绘制折线图的 WinForms Chart 控件。 I tried with charting provided by WPF Toolkit, but the memory consumption is increasing.我尝试使用 WPF Toolkit 提供的图表,但内存消耗在增加。 I am displaying a local HTML file with javascript to show a location on Google Map.我正在使用 javascript 显示本地 HTML 文件以在 Google 地图上显示位置。 The location is updated every 100 ms.该位置每 100 毫秒更新一次。 Along with the location, some other data is received which I have to display on the Line Chart.除了位置,还收到了一些其他数据,我必须在折线图上显示这些数据。

While testing, I have observed that the graph and browser both are updating well simulataneously with 500 ms interval.在测试时,我观察到图形和浏览器都以 500 毫秒的间隔同时更新。 But when the frequency is changed to 100 ms, the browser stops updating.但是当频率更改为 100 ms 时,浏览器停止更新。 It is also observed that if data plotting on the chart is stopped, the browser tiles load back again and location is updating.还观察到,如果停止在图表上绘制数据,浏览器磁贴会再次加载,并且位置正在更新。

Any hint as to what the problem might be??关于问题可能是什么的任何提示?

This sounds like a classic example of either a very busy main thread (UI thread) that is updating the chart is starving out main thread updates to the web browser control.这听起来像是正在更新图表的非常繁忙的主线程(UI 线程)正在耗尽对 Web 浏览器控件的主线程更新的经典示例。 Or if you have separate threads, other than the main thread, updating the chart and the web browser, again the I/O latency updating the chart is short compared to the I/O latency updating the web browser and therefore the chart update thread is starving out the web browser updates.或者,如果除了主线程之外,您有单独的线程来更新图表和 Web 浏览器,那么与更新 Web 浏览器的 I/O 延迟相比,更新图表的 I/O 延迟同样较短,因此图表更新线程是饿死网络浏览器更新。 Even if the web browser updates and the chart updates are sourced from separate threads, other than the UI thread, one thread can starve out the other.即使 web 浏览器更新和图表更新来自不同的线程,而不是 UI 线程,一个线程可能会饿死另一个线程。 There too many ways to fix this to list here.解决这个问题的方法太多了,这里就不一一列举了。 You just have to make sure the threads doing the updates to the chart and web browser control have an balanced/equal chance to get a time slice to do their thing.您只需要确保对图表和 Web 浏览器控件进行更新的线程有平衡/平等的机会来获得时间片来做他们的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM