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).aspxpull/3409/head
parent
7115e244b4
commit
4d0944b037
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue