Good Async pattern for sequential WebClient requests

Posted by Omar Shahine on Stack Overflow See other posts from Stack Overflow or by Omar Shahine
Published on 2010-03-19T16:29:35Z Indexed on 2010/03/19 16:31 UTC
Read the original article Hit count: 521

Most of the code I've written in .NET to make REST calls have been synchronous. Since Silverlight on Windows Phone only supports Async WebClient and HttpWebRequest calls, I was wondering what a good async pattern is for a Class that exposes methods that make REST calls.

For example, I have an app that needs to do the following.

  1. Login and get token
  2. Using token from #1, get a list of albums
  3. Using token from #1 get a list of categories
  4. etc

my class exposes a few methods:

  1. Login()
  2. GetAlbums()
  3. GetCategories()

since each method needs to call WebClient using Async calls what I need to do is essentially block calling Login till it returns so that I can call GetAlbums().

What is a good way to go about this in my class that exposes those methods?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about windows-phone-7