katit
katit

Reputation: 17895

Async update of UI

I have datagridview and need to update it on separate 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?

Upvotes: 0

Views: 1201

Answers (3)

Pete M
Pete M

Reputation: 2038

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?

Upvotes: 0

ProgrammerAl
ProgrammerAl

Reputation: 787

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.

Upvotes: 0

Matt Greer
Matt Greer

Reputation: 62027

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.

Upvotes: 2

Related Questions