title: Lazy<T> with expiration time
body: <p>I want to implement an expiration time on a Lazy object.
  The expiration cooldown must start with the first retrieve of the value.
  If we get the value, and the expiration time is passed, then we reexecute the function and reset expiration time.</p>
  
  <p>I'm not familiar with extensions, partial keyword, and I don't know the best way to do that.</p>
  
  <p>Thanks</p>
  
  <p>EDIT :</p>
  
  <p>The code so far :</p>
  
  <p>NEW EDIT :</p>
  
  <p>the new code : </p>
  
  <pre><code>public class LazyWithExpiration&lt;T&gt;
  {
      private volatile bool expired;
      private TimeSpan expirationTime;
      private Func&lt;T&gt; func;
      private Lazy&lt;T&gt; lazyObject;
  
      public LazyWithExpiration( Func&lt;T&gt; func, TimeSpan expirationTime )
      {
          this.expirationTime = expirationTime;
          this.func = func;
  
          Reset();
      }
  
      public void Reset()
      {
          lazyObject = new Lazy&lt;T&gt;( func );
          expired = false;
      }
  
      public T Value
      {
          get
          {
              if ( expired )
                  Reset();
  
              if ( !lazyObject.IsValueCreated )
              {
                  Task.Factory.StartNew( () =&gt;
                  {
                      Thread.Sleep( expirationTime );
                      expired = true;
                  } );
              }
  
              return lazyObject.Value;
          }
      }
  
  }
  </code></pre>