diff --git a/aspnet/web-api/overview/advanced/httpclient-message-handlers/samples/sample2.cs b/aspnet/web-api/overview/advanced/httpclient-message-handlers/samples/sample2.cs index 5f4c540877..8899a7735d 100644 --- a/aspnet/web-api/overview/advanced/httpclient-message-handlers/samples/sample2.cs +++ b/aspnet/web-api/overview/advanced/httpclient-message-handlers/samples/sample2.cs @@ -5,8 +5,8 @@ class MessageHandler1 : DelegatingHandler protected override Task 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); } -} \ No newline at end of file +}