diff --git a/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj.DotSettings b/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj.DotSettings new file mode 100644 index 0000000000..58ad6c8854 --- /dev/null +++ b/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp71 \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Threading/HttpContextCancellationTokenProvider.cs b/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Threading/HttpContextCancellationTokenProvider.cs new file mode 100644 index 0000000000..4757ce2f93 --- /dev/null +++ b/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Threading/HttpContextCancellationTokenProvider.cs @@ -0,0 +1,20 @@ +using System.Threading; +using Microsoft.AspNetCore.Http; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Threading; + +namespace Volo.Abp.AspNetCore.Threading +{ + [Dependency(ReplaceServices = true)] + public class HttpContextCancellationTokenProvider : ICancellationTokenProvider, ITransientDependency + { + public CancellationToken Token => _httpContextAccessor.HttpContext?.RequestAborted ?? default; + + private readonly IHttpContextAccessor _httpContextAccessor; + + public HttpContextCancellationTokenProvider(IHttpContextAccessor httpContextAccessor) + { + _httpContextAccessor = httpContextAccessor; + } + } +}