smatter
smatter

Reputation: 29178

Improving UI responsiveness with seperate worker thread for async tasks

My silverlight application fetches two sets of files from an asmx webservice (say set A and set B, set A has a few files and set B has a large number of files) asynchronously. On receiving each file in a set, it should be parsed and some data structures need to be updated. As soon as the whole set A is received, an async request is made to the webservice to fetch set B.

When set A is received, the application is ready to use. But since the files are still being received from set B, the UI is not very responsive. Is there any way to improve the responsiveness while files are being fetched and processed in background. Does async_task_completed of webservice handlers work on different threads. Does it make sense to have a BackgroundWorker thread?

EDIT: Just to clarify, async request for a set (hundreds of files) are issued together.

Upvotes: 2

Views: 262

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189457

Take the guess work out of the equation. Just drop this line temporarily into the completion code of your web service calls.

MessageBox.Show(Deployment.Current.Dispatcher.CheckAccess().ToString());

If you see "True" you are on the UI thread and so you (at least) need to get off it to do your processing. As you suggest an easy way to do that is use a BackgroundWorker.

If you see "False" you are on a background thread already so your performance issues if of another source.

Upvotes: 2

Related Questions