Skip to Content
Data-Driven Services with Silverlight 2
book

Data-Driven Services with Silverlight 2

by John Papa
December 2008
Intermediate to advanced
368 pages
11h 2m
English
O'Reilly Media, Inc.
Content preview from Data-Driven Services with Silverlight 2

Invoking a RESTful Service with WebClient

The following example will demonstrate the steps required to invoke a RESTful web service using WebClient. You can find the complete example code in the book’s code folder for this chapter. The sample displays a Silverlight 2 client application’s DiggStoryView.xaml control, shown in Figure 7-5, which allows the user to retrieve the most recent stories from the RESTful Digg.com web service.

The DiggStoryView.xaml control

Figure 7-5. The DiggStoryView.xaml control

The WebClient class invokes asynchronous operations that fire off events when they have completed their respective tasks. Some of the asynchronous operations also fire events that contain information regarding the progress of the asynchronous operations. WebClient contains the asynchronous operations shown in Table 7-1.

Only one request can be made to an asynchronous operation at a time using WebClient. If a second asynchronous operation is invoked, an exception will be thrown. When event handlers are added to the WebClient class’s events, the code in the handler executes in the UI thread, not in the background thread. This is significant because by operating on the UI thread, any code executing in the event handler can get values, set values, and interact with controls in the Silverlight client application’s UI without any special coding. The WebClient API has a very simple interface that makes it easy to use. It ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Professional C# 5.0 and .NET 4.5.1

Professional C# 5.0 and .NET 4.5.1

Christian Nagel, Jay Glynn, Morgan Skinner
Pro C# 7: With .NET and .NET Core

Pro C# 7: With .NET and .NET Core

Andrew Troelsen, Philip Japikse
C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet
C# 7 and .NET Core Cookbook - Second Edition

C# 7 and .NET Core Cookbook - Second Edition

Fabio Claudio Ferracchiati, Dirk Strauss

Publisher Resources

ISBN: 9780596156688Errata Page