public void RequestRefresh(EntitySelectionCacheRefreshType refreshType = EntitySelectionCacheRefreshType.Light) { if (!this.BlockRequests) { try { this.AccessControl.WaitOne(); TimeSpan offset = this.GetSuggesstionOffset(refreshType); if (!this.BlockRequests && this.LastRefreshTime.Add(offset) < DateTime.Now && (this.Searcher == null || !this.Searcher.Busy)) { this.Searcher = new SearchContext(this.Context, this.ModelName, new Dictionary<string, string>()); this.Searcher.OnComplete += this.RefreshCache; this.Searcher.Begin(); } } finally { this.AccessControl.ReleaseMutex(); } } }
private TimeSpan GetSuggesstionOffset(EntitySelectionCacheRefreshType type) { switch (type) { case EntitySelectionCacheRefreshType.Light: return LightRefreshOffset; case EntitySelectionCacheRefreshType.Strong: return StrongRefreshOffset; case EntitySelectionCacheRefreshType.Force: return ForceRefreshOffset; } return LightRefreshOffset; }