aAaBEAeXW~Y| 4649664VCBCXB

HttpClient.` Files from the Internet must often be accessed. This requires more time due to reduced locality. During this time, a program can perform other tasks.`Class, notes.` The .NET Framework provides a HttpClient class that makes downloading files on separate threads easier. It helps simplify syntax.`To start,` we use the async and await keywords. In Main, we start a task and use DownloadPageAsync, an async method, as the target. This method is started—it downloads a web page. `In DownloadPageAsync, we use 3 using-statements. This helps improve system resource usage.`Await: `We use the await keyword twice. We first call GetAsync and then ReadAsStringAsync. And finally we display the result string.`Using `using`Strings `string`A discussion.` The functionality of HttpClient overlaps with WebClient. The syntax of these two types is different. WebClient does not currently support the async and await syntax. `With WebClient, its "Async" method uses an object token. This is more clumsy.`WebClient `webclient`Therefore: `If async and await are used in the program, the HttpClient is preferable—it gains compiler checking and improved syntax.`A summary.` HttpClient provides powerful functionality with better syntax support for newer threading features. It supports the await keyword.`HttpClient enables` threaded downloads of Internet files with better compiler checking and code validation. It requires newer versions of the .NET Framework. `Async, Await `async

IFBVxBBFDFQ;BFDFQ.Net.Http;BFDFQ.Threading.TasksFbFJFAB{BIF%I{BIITask tFyFqTask(DownloadPageAsync);BIIt.F`();BIIF'xVDownloading page...Vx);BIIF5.FuLine();BI}BBIF?async FcDownloadPageAsync()BI{xBIIF9Target page.BIIxFP pageFyxVhttp://en.wikipedia.org/Vx;xBBIIF9Use HttpClient.BIIxFD(xHttpClientx clientFyFqHttpClient())BIIFD(HttpResponseMessage responseFyawait client.GetAsync(page))BIIFD(HttpContent contentFyresponse.Content)BII{xBIIIF9Fu the FP.BIIIxFP FMFyawait content.FuAsFOAsync();xBBIIIF9F= the FM.BIIIxFmFM != null &&BIIIIFM.LF^ >= 50)BIII{BIIIIF'FM.SubFP(0, 50)F}xV...Vx);BIII}BII}BI}B}BBxBBDownloading page...B<!DOCTYPE html>B<html lang=VenV dir=VltrV class=Vc...x

!ZHttpClient