问题
I am creating an application.and i am scanning files of a drive to search a particular pattern my progress bar is getting updated and at the end all the file names are listed in the list box.i want the all those files to be listed immediately as soon as its found that they contain the pattern.
I'm using BackgroundWorker
回答1:
Use the ReportProgress method in combination with the ProgressChanged event. This type of scenario is exactly what they are intended for.
回答2:
You can use ReportProgress method of background worker.
http://msdn.microsoft.com/en-us/library/a3zbdb1t.aspx
回答3:
You would need to implement a foreground worker and invoke it from the background worker.
Ideally, you would be passing a list of any newly found files to the foreground worker.
来源:https://stackoverflow.com/questions/3627967/how-do-i-add-values-to-my-list-box-while-my-background-proccessing-is-going-on