.net - GUI freeze while loading data in BackgroundWorker -
i have listview
control receiving data backgroundworker
through reportprogress
. worker dumps hundred rows in quick succession. each chunk of data fires progresschanged
event , gui thread adds new item listview
.
as data retrieval operations run on separate thread, gui supposed update on every change. reason doesn't happen - interface remains frozen until worker completed.
any ideas?
also, tests done on fast machine, don't think computer performance issue.
it's winforms application.
put in bgw worker loop, after reportprogress call:
system.threading.thread.sleep(15);
odds see listview updating. what's going on here ui thread getting flooded delegate invoke requests. dispatched before paint notification. if next invoke request arrives before previous 1 has finished running never gets around doing normal housekeeping tasks. painting , responding input. items added list view, can't see being done.
call reportprogress less often. doing more 25 times per second waste of resources, no human can see difference. let bgw store items in list<> , cut down on ui thread overhead calling addrange().
Comments
Post a Comment