/// <summary> /// The CacheLoader has finished loading and is handing us a new value. /// </summary> void Cached_ValueAvailable(object sender, ValueAvailableEventArgs e) { // live loader has data, so we don't care about it anymore. // if (HaveWeEverGottenALiveValue) { NextCompletedAction.UnregisterLoader(LoaderType.CacheLoader); return; } // copy the cached value into our state. // UpdateFrom((ValueLoader)sender, e.Value); SetBoolValue(UsingCachedValueMask, true); UpdateExpiration(e.UpdateTime, e.Value as ICachedItem); }
/// <summary> /// Callback that fires when the LiveValueLoader has completed it's load and is handing /// us a new value. /// </summary> void Live_ValueAvailable(object sender, ValueAvailableEventArgs e) { // is this the same value we already have? // if (e.UpdateTime == LastUpdatedTime) { return; } // update update and expiration times. // var value = e.Value; ValueLoader loader = (ValueLoader)sender; UpdateExpiration(e.UpdateTime, value as ICachedItem); if (value != null) { UpdateFrom(loader, value); } else { // not clear what to do with null values. // NotifyCompletion(loader, null); return; } HaveWeEverGottenALiveValue = true; // We are no longer using the cached value. // SetBoolValue(UsingCachedValueMask, false); // as long as this thing isn't NoCache, write // it to the store. // if (CachePolicy != AgFx.CachePolicy.NoCache) { SerializeDataToCache(value, _liveLoader.UpdateTime, _valueExpirationTime, false); } }
/// <summary> /// Callback that fires when the LiveValueLoader has completed it's load and is handing /// us a new value. /// </summary> void Live_ValueAvailable(object sender, ValueAvailableEventArgs e) { // is this the same value we already have? // if (e.UpdateTime == LastUpdatedTime) { return; } // update update and expiration times. // var value = e.Value; ValueLoader loader = (ValueLoader)sender; UpdateExpiration(e.UpdateTime, value as ICachedItem); if (value != null) { UpdateFrom(loader, value); } else { // not clear what to do with null values. // NotifyCompletion(loader, null); return; } HaveWeEverGottenALiveValue = true; // We are no longer using the cached value. // SetBoolValue(UsingCachedValueMask, false); // as long as this thing isn't NoCache, write // it to the store. // if (CachePolicy != CachePolicy.NoCache) { SerializeDataToCache(value, _liveLoader.UpdateTime, _valueExpirationTime, false); } }