I've been experimenting with the BackgroundWorker class. As a test, I've
built an application that searches for files matching a RegEx and populates
a listbox with the results.
My approach is to search directories recursviely andcall ReportProgress once
per directory or in batches of 10 matching files if there are a lot of
results. I pass an ArrayList containing the matching filenames. In the
ProgressChanged event handler I add the matching filenames to a listbox.
When I first ran the app, and if I use a blank RegEx matching all files, I
was surprised to find the UI frozen during the search just as if I were not
using BackgroundWorker. I've found I can fix this by inserting a call to
Thread.Sleep(1) just after I call ReportProgress.
Can someone explain why this is so?
Tim