public void SetCacheWorkItem(CacheWorkItem item) { lock (this.sync) { this.cacheWorkItem = item; this.cacheWorkWait.Set(); } }
/// <summary> /// Deletes all unused containers where the work item does not match <paramref name="current_work_item"/>. /// Must be called after <see cref="ImageContainer.last_requesting_work_item"/> has been set for all elements that should remain. /// </summary> internal void PruneUnusedContainers(CacheWorkItem current_work_item) { var disposableContainers = new List <ImageContainer>(); lock (this.cache) { this.current_work_item = current_work_item; foreach (ImageContainer container in this.cache.Values.ToArray()) { if (container.last_requesting_work_item != this.current_work_item && !container.IsHandleAlive) { // Do not dispose here while we're in the lock - the Dispose might take a relatively long time. disposableContainers.Add(container); this.cache.Remove(container.Key); } } } ThreadPool.QueueUserWorkItem(this.disposeManyContainersHelperDelegate, disposableContainers); }