[DSI-8257] Simplify flow of cancellation tokens through .NET applications and interactions #99
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 came up whilst reviewing the PR for the recently introduced .NET profile component.
It is quite easy for developers to inadvertently omit passing cancellation tokens from application controllers to interactions when dispatching them via
IInteractionDispatcher.This PR introduces
ICancellationContextwhich automatically manages the flow of cancellation tokens through the interaction framework.In most cases developers can now dispatch requests without having to worry about manually passing cancellation tokens:
or in the case of when mapped to a view model:
Request's that should never be cancellable can be annotated with the
[NonCancellable]attribute; for example,Developers are still able to explicitly override cancellation tokens if needed (unless
[NonCancellable]is specified); for example,or in the case of when mapped to a view model:
It is also possible to create new cancellation scopes with the following syntax: