Change tokens can call into your code IMMEDIATELY when you subscribe. I
reviewed our other usage of ChangeToken.OnChange in MVC and everything
looks good.
This commit is contained in:
Ryan Nowak 2018-09-13 15:16:36 -07:00
parent cb88e906b2
commit 35597db277
2 changed files with 5 additions and 2 deletions

View File

@ -33,11 +33,12 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
_actionDescriptorChangeProviders = actionDescriptorChangeProviders.ToArray();
_lock = new object();
// IMPORTANT: this needs to be the last thing we do in the constructor. Change notifications can happen immediately!
ChangeToken.OnChange(
GetCompositeChangeToken,
UpdateCollection);
_lock = new object();
}
/// <summary>

View File

@ -58,6 +58,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
ConventionalEndpointInfos = new List<MvcEndpointInfo>();
// IMPORTANT: this needs to be the last thing we do in the constructor. Change notifications can happen immediately!
//
// It's possible for someone to override the collection provider without providing
// change notifications. If that's the case we won't process changes.
if (actions is ActionDescriptorCollectionProvider collectionProviderWithChangeToken)