dazinator / serviceprovider-experiment

0 stars 0 forks source link

Cancellable Scopes #1

Open dazinator opened 4 years ago

dazinator commented 4 years ago

when disposing the sp, it should be able to signal its scopes to dispose early via a cancellation token.

If running within a request scope, such as an mvc controller method, this could be done by:

Middleware extending following cancellation token

HttpContext.RequestAborted

To one that will also be triggered on IServiceProvider.DisposeAsync.

Or in the case of a background job, when creating a scope, cast the scope to ICancellableScope to get the access token, or perhaps consider making it possible to just resolve an ICancellationToken?

dazinator commented 4 years ago

Good info https://www.google.com/amp/s/andrewlock.net/using-cancellationtokens-in-asp-net-core-mvc-controllers/amp/