In WebClient, events such as DownloadProgressChangedEventHandler can respond to the progress of http requests (or other web requests.
In c #5.0, all HttpClient functions exist as Task asynchronous functions. No event can be called back to display the upload or download progress.
After a long time, I finally found that ProgressMessageHandler can solve this problem,
Sample Code
HttpClientHandler hand = new HttpClientHandler ();
ProgressMessageHandler processMessageHander = new ProgressMessageHandler (hand );
HttpClient localHttpClient = new HttpClient (processMessageHander );
HttpRequestMessage httpRequestMessage = new HttpRequestMessage ();
HttpRequestMessage. Method = HttpMethod. Put;
HttpRequestMessage. Content = new StreamContent (content );
// For upload
ProcessMessageHander. HttpSendProgress + = (sender, e) =>
{
Int num = e. ProgressPercentage; // you can use HttpProgressEventArgs e
};
// For download
// ProcessMessageHander. HttpReceiveProgress ++ = (sender, e) =>
//{
// Int num = e. ProgressPercentage;
//};
HttpResponseMessage test = await localHttpClient. SendAsync (httpRequestMessage );
// Dispose the resource