My silverlight application fetches file sets from a webservice (async). The webservice method accepts an array of file names and returns the set of files (also as an array). The silverlight client makes several such requests for file sets.
The client issues many requests to the webservice at once. I need a BackgroundWorker thread at the client to process received file sets one after the other.
How can I collect all the file sets as and when they receive and give these sets to the BackgroundWorker thread one at a time.
EDIT:
I could not run multiple BackgorundWorkers as the file set processing module is not thread-safe.
Use a
BlockingCollection/ConcurrentQueueto hold the information about file sets to be processed… in the backgroundworker you just havewhileloop dequeuing the next file set and processing it… the mentioned collections are threadsafe and really fast since most operations are implemented lock-free…