How to use the WebClient.DownloadDataAsync() method in this context?

前端 未结 6 1663
北荒
北荒 2020-12-01 18:01

My plan is to have a user write down a movie title in my program and my program will pull the appropiate information asynchronously so the UI doesn\'t freeze up.

Her

6条回答
  •  忘掉有多难
    2020-12-01 18:43

    There is a newer DownloadDataTaskAsync method that allows you to await the result. It is simpler to read and easier to wire up by far. I'd use that...

    var client = new WebClient();
    
    var data = await client.DownloadDataTaskAsync(new Uri(imageUrl));
    
    await outstream.WriteAsync(data, 0, data.Length);
    

提交回复
热议问题