Nope, the callback only gets fired once (with the cached data). I debugged it and I think I found the cause. In Invalidate(), it sets the CacheEntry's expiration date to Now (so it is expired), but then later when LoadInternal checks the CacheValueLoader's
IsValid property, its
expiration date is still in the future (assuming the cache has not expired yet based on its configuration). At that point, it calls StartLoading with force=false and passing in the CacheValueLoader, which results in the callback
being fired with the cached data.
I tried changing the SetForRefresh() method to always call _cacheLoader.SetExpired(), but that doesnt actually update the CacheValueLoader's expiration time (instead, it sets the state to Error, and doing so resulted in some strange behavior). I then modified
the CacheValueLoader.SetExpired() method to set its expiration date to Now, and that seems to work OK, though I also had to comment out the part about setting the state to Error, so I am not sure of what downstream effects it is having.
Since I am using this in a background agent and need to wait for the Refresh() to complete, my other work-around is to call LoadFromCache() first (which is synchronous) and then call Refresh. That works but unnecessarily slows things down since I dont want/use
the cached value read from disk.
Anyway, I figure with the holidays that this would be something that wouldnt be fixed right away and it is not blocking me since I have a few work-arounds, but I thought I would report it so you could take a look.