How do i add values to my list box while my background proccessing is going on?

最后都变了- 提交于 2019-12-02 16:51:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!