Explicitly maintain a reference to a _HandlerDelegate's task. #3319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This ensures that, when an async task for an HTTP handler delegate is running, a strong reference is maintained at all times by the delegate itself.
This is a complement to #3269. While that change creates a global store of running tasks, this one independently stores it locally.
This is essentially a suggestion of one other possible way that we could Do The Right Thing in the web module rather than just relying on the global store. Empirically, it appears to be working correctly (i.e., all tasks maintain a reference and run to completion) when running this, given that this branch does not contain #3269.
My feeling is that even with that other change, we should still do this (or something like it) to avoid the semi-undocumented dependency on the global strong task store. This particular implementation is something I threw together, and I invite suggestions, or you could even simply take the concept and reimplement it however you prefer.