Refresh control while Backgroundworker_doWork

Xancholy

Well-known member
Joined
Aug 29, 2006
Messages
143
Programming Experience
Beginner
I have a backgroundworker populating a imagelist control with thumbnails on form load.

As there are many images, there is some flicker on the control.

How can I reduce flicker/refresh the control as the backgroundworker progresses ?

Thanks
 
Honestly, I haven't tried it either. I'm waiting for someone else to and let me know how it works ;)

Only problem I see with it is that it will probably lock out input on the form while it's refreshing.
 
Only problem I see with it is that it will probably lock out input on the form while it's refreshing.

thus defeating the purpose of the backgroundworker!:rolleyes:

JB, do you have a code sample of using reportprogress to update a UI control ?
 
Set the background worker's ReportProgress property to True.

Then in your DoWork event use the .ReportProgress(Integer, Object) to report the progress. If you're not actually doing a percent "%", then any bogus Integer can be used and you use the Object (second parameter) to pass whatever other information you want. I typically pass file names using the second parameter. Then use the Background worker's ReportProgress event to update whatever controls you want on the gui thread (your form).

Be sure to cast your object from the e args back to the type of variable you set it in in the DoWork event before you use it.
 
Back
Top