public void DownloadDataCompletedExample()
{
var waitForAsync = new ManualResetEvent(false);
var webClient = new WebClient();
byte[] result = null;
webClient.DownloadDataCompleted += (sender, args) =>
{
if (args.Error != null)
{
throw args.Error;
}
else
{
result = args.Result;
}
waitForAsync.Set();
};
webClient.DownloadDataAsync(new Uri("http://www.google.com/"));
waitForAsync.WaitOne();
Assert.IsNotNull(result);
}