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: 548
Silverlight
|windows-phone-7
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.
- Login and get token
- Using token from #1, get a list of albums
- Using token from #1 get a list of categories
- etc
my class exposes a few methods:
- Login()
- GetAlbums()
- 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