Reputation: 4480
I am creating a background worker thread and Loading data in it and showing in UI. I know the problem is while showing the data in UI(because it is a UI thread) But i get the data from server in form of blocks . Suppose for the first time receive 10 records then i have to update the Ui and then call the next records.
How to resolve this Issue ? Thanks.
Upvotes: 0
Views: 180
Reputation: 60724
If you are using a BackgroundWorker
you have to make use of the report progress feature.
What I usually do is to do the work required inside the DoWork method, and when you want to update the GUI, call worker.ReportProgress
with the needed data. Then in the report progress method, update the GUI since that method will be run on the GUI thread. Also make sure you set WorkerReportsProgress
to true, else you will get an exception when trying to call ReportProgress
.
Upvotes: 1