src/Shared/EntityFramework/Internal/RetryLazy`.cs
// <summary>
// Gets the value, possibly by running the initializer if it has not been run before or
// if all previous times it ran resulted in exceptions.
// </summary>
// <param name="input"> The input to the initializer; ignored if initialization has already succeeded. </param>
// <returns> The initialized object. </returns>
Gets the value, possibly by running the initializer if it has not been run before or
if all previous times it ran resulted in exceptions.
Gets the value possibly by running the initializer if it has not been run before or if all previous times it ran resulted in exceptions .
[DebuggerStepThrough]
        public TResult GetValue(TInput input)
        {
            lock (_lock)
            {
                if (_value == null)
                {
                    Debug.Assert(_valueFactory != null, "Same thread called Value while already calculating Value.");
                    var valueFactory = _valueFactory;
                    try
                    {
                        _valueFactory = null;
                        _value = valueFactory(input);
                    }
                    catch (Exception)
                    {
                        Debug.Assert(_value == null, "_value should only be set if no exception is thrown.");
                        _valueFactory = valueFactory;
                        throw;
                    }
                }
                Debug.Assert(_value != null, "This class needs modification if it should ever return null.");
                return _value;
            }
        }
[ DebuggerStepThrough ] public TResult GetValue ( TInput input ) { lock ( _lock ) { if ( _value == null ) { Debug . Assert ( _valueFactory != null , " " ) ; var valueFactory = _valueFactory ; try { _valueFactory = null ; _value = valueFactory ( input ) ; } catch ( Exception ) { Debug . Assert ( _value == null , " " ) ; _valueFactory = valueFactory ; throw ; } } Debug . Assert ( _value != null , " " ) ; return _value ; } }
Gets the value, possibly by running the initializer if it has not been run before or
if all previous times it ran resulted in exceptions.
Gets the value possibly by running the initializer if it has not been run before or if all previous times it ran resulted in exceptions .
// This code is taken from System.Lazy with the parts of that class that we are not using removed // and with extra logic to allow initialization retry. // Reset the value factory so that the value creation will be retried.
The initialized object.
The initialized object .
input
TInput
The input to the initializer; ignored if initialization has already succeeded.
The input to the initializer ; ignored if initialization has already succeeded .