开发者

Async update of UI

I have datagridview and need to update it on sepa开发者_如何学Crate thread. Or maybe even on same thread but only when data ready. I have 90% of data loading right away and would like to show it to user. Then I have 2 more columns that can load 20+ seconds sometimes and would like to update them as soon as data ready. What is the best way to accomplish this?


In WinForms, your best bet is BackgroundWorker, it's a nice class for doing work on a different thread and updating a WinForms based UI.


Having not seen any code, I would suggest creating your own event. Once the data is ready, you throw a new event with the new data as the argument, and then load that. It'll happen on the same UI thread though.

Not sure if you already have a way to poll for that being completed. Making a thread to run in the background and just poll for that wouldn't be too hard.


Where is the remaining 10% of your data coming from? What are you binding to? Is this a scenario where you're making one hit to your data source for the "90%" and then making a totally separate hit to go get the rest of your data?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜