.net異步編程

     public async Task<string> Get()
        {
            return await GetArticleContentAsync();
        }

        private async Task<string> GetArticleContentAsync()
        {
            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync("http://www.asp.net");
                var buffer = await response.Content.ReadAsByteArrayAsync();
                return Encoding.UTF8.GetString(buffer);
            }
        }
相關文章
相關標籤/搜索