简体   繁体   中英

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

I have a WPF application with two windows. One window contains a WebBrowser control. The other window contains a WindowsFormsHost which hosts a WinForms Chart control for drawing a line chart. I tried with charting provided by WPF Toolkit, but the memory consumption is increasing. I am displaying a local HTML file with javascript to show a location on Google Map. The location is updated every 100 ms. 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. But when the frequency is changed to 100 ms, the browser stops updating. 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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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