public virtual async Task OnCloseAsync(TimeSpan timeout) { if (SecurityProtocolFactory.ActAsInitiator) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); foreach (SupportingTokenProviderSpecification spec in ChannelSupportingTokenProviderSpecification) { await SecurityUtils.CloseTokenProviderIfRequiredAsync(spec.TokenProvider, timeoutHelper.RemainingTime()); } foreach (string action in ScopedSupportingTokenProviderSpecification.Keys) { ICollection <SupportingTokenProviderSpecification> supportingProviders = ScopedSupportingTokenProviderSpecification[action]; foreach (SupportingTokenProviderSpecification spec in supportingProviders) { await SecurityUtils.CloseTokenProviderIfRequiredAsync(spec.TokenProvider, timeoutHelper.RemainingTime()); } } } }