private void SearchExecuteUpdateCache(ItemEditType type, int[] ids = null) { new Thread(new ParameterizedThreadStart((obj) => { Tuple <ItemEditType, int[]> tu = (Tuple <ItemEditType, int[]>)obj; using (m_lockCache.WriteLock()) { SearchRequest[] keys = m_cacheSR.Keys.ToArray(); foreach (var ki in keys) { SearchResult sr = null; switch (tu.Item1) { case ItemEditType.ADD_NEW_ITEM: sr = SearchGetIDs_(ki); break; case ItemEditType.REMOVE_ITEM: sr = m_cacheSR[ki]; int[] idr = tu.Item2; if (sr.IDs != null && sr.IDs.Length > 0 && idr != null && idr.Length > 0) { int[] val = sr.IDs.Where(x => !tu.Item2.Any(o => o == x)).ToArray(); sr.IDs = val; sr.Total = val.Length; } break; } m_cacheSR[ki] = sr; } } })).Start(new Tuple <ItemEditType, int[]>(type, ids)); }
public void BuildCache(IList list, ItemEditType type, int[] ids = null) { using (cacheLock.WriteLock()) { SearchRequest[] keys = cacheStore.Keys.ToArray(); foreach (var ki in keys) { SearchResult sr = null; switch (type) { case ItemEditType.ADD_NEW_ITEM: sr = SearchGetIDs_(list, ki); break; case ItemEditType.REMOVE_ITEM: sr = cacheStore[ki]; if (sr.IDs != null && sr.IDs.Length > 0 && ids != null && ids.Length > 0) { int[] val = sr.IDs.Where(x => !ids.Any(o => o == x)).ToArray(); sr.IDs = val; sr.Total = val.Length; } break; } cacheStore[ki] = sr; } } }