Beispiel #1
0
        private async Task <RawDataServiceFeatureMatrix> GetFeatureMatrixInternal(FetchBehavior behavior, CancellationToken cancellationToken = default(CancellationToken))
        {
            // This is an intentional race condition. Calling this method from multiple threads may lead to multiple calls to Get<InterfaceInformation>().
            // However, this would be rare and harmless, since it should always return the same result. It would be a lot more difficult to make this work without any races or blocking.
            // It is important to never set _LastValidServiceInformation to null anywhere to avoid possible null returns here due to the race condition.
            if (behavior == FetchBehavior.FetchAlways || _FeatureMatrix == null)
            {
                var interfaceVersionRange = await GetInterfaceInformation(cancellationToken).ConfigureAwait(false);

                _FeatureMatrix = new RawDataServiceFeatureMatrix(interfaceVersionRange);
            }

            return(_FeatureMatrix);
        }
Beispiel #2
0
        private async Task <ServiceInformation> GetServiceInformationInternal(FetchBehavior behavior, CancellationToken cancellationToken = default(CancellationToken))
        {
            // This is an intentional race condition. Calling this method from multiple threads may lead to multiple calls to Get<ServiceInformation>().
            // However, this would be rare and harmless, since it should always return the same result. It would be a lot more difficult to make this work without any races or blocking.
            // It is important to never set _LastValidServiceInformation to null anywhere to avoid possible null returns here due to the race condition.
            if (behavior == FetchBehavior.FetchAlways || _LastValidServiceInformation == null)
            {
                var serviceInformation = await _RestClient.Request <ServiceInformation>(RequestBuilder.CreateGet("ServiceInformation"), cancellationToken).ConfigureAwait(false);

                _LastValidServiceInformation = serviceInformation;
            }

            return(_LastValidServiceInformation);
        }