Mitigate possible race condition in MessageHandler1 (#3402)

MSDN description of DelegatingHandler Class says:
"Any instance members are not guaranteed to be thread safe"
https://msdn.microsoft.com/en-us/library/system.net.http.delegatinghandler(v=vs.118).aspx
pull/3409/head
Andrii Bratanin 2017-05-24 04:14:52 +03:00 committed by Rick Anderson
parent 7115e244b4
commit 4d0944b037
1 changed files with 2 additions and 2 deletions

View File

@ -5,8 +5,8 @@ class MessageHandler1 : DelegatingHandler
protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
_count++;
System.Threading.Interlocked.Increment(ref _count);
request.Headers.Add("X-Custom-Header", _count.ToString());
return base.SendAsync(request, cancellationToken);
}
}
}