BackgroundWorker [duplicate]
Possible Duplicates:
backgroundthread How do i add values to my list box while my background proccessing is going on?
by list i mean a list Box.i am col开发者_StackOverflow中文版lecting the file names in a array list object and put the same in list box but not in the completed work of BackgroundWorker,i want to show the files in the list box immediately after the pattern is found in it
Use the ReportProgress
method of the BackgroundWorker to wrap up the data you want to add to the list box and call it in your threaded code.
Then subscribe to the BackgroundWorker's ProgressChanged
event (usually your form will do this) - unwrapping the data and then adding it to the listbox whenever it's called.
EDIT This is exactly the same answer as the top-voted one on your previous question!
So while originally I wasn't too worried about the dupes that other people have spotted because it looked like they were just bad questions - in fact it appears you've asked a much better question previously and have now duped it with this inferior one; only to get the same answer!
Ignore the SO community at your peril! When you're given answer, don't ignore it by asking the same question again! Fredrik deserves credit for answering you before!.
If you don't know how to use ProgressChanged - ask another question along the lines of "How do I use the BackgroundWorker.ProgressChanged event to transmit data?"
精彩评论