-
Notifications
You must be signed in to change notification settings - Fork 6
Use .ContinueWith instead of finally for removal. #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows non-async/await and Task-based handling to complete and still remove the scope without the try/finally removing it before the task is finished.
@russellfoster @srogovtsev Give this a look, I think I got it. If you don't have time, no biggie, but thought you'd be interested. Plus, I have to admit my |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with two questions. 👍
test/Autofac.Integration.WebApi.Owin.Test/DependencyScopeHandlerFixture.cs
Outdated
Show resolved
Hide resolved
You'd also need a test for cancelled tasks, something like: var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Cancel();
var fakeHandler = new FakeInnerHandler(_ =>
{
return Task.Factory.StartNew<HttpResponseMessage>(async () =>
{
//this should cancel immediately
await Task.Delay(-1, cancellationTokenSource.Token);
//we never get here, but the compiler doesn't know it
return new HttpResponseMessage(HttpStatusCode.OK);
});
}); |
|
The newer analyzers are better but since this targets `net472` we don't get them by default like we do for .NET Core.
Pushing this through. I think I got everything and it should at least unblock folks who were affected by the issue. We can tweak which scheduler to use later if we need to. |
This allows non-async/await and Task-based handling to complete and still remove the scope without the try/finally removing it before the task is finished.
Based on comments for #17.