public IServiceResult GetORIsOfService(IServiceDescription serviceDescription, ExecuteServiceDelegate executeServiceDelegate) { if (!UseResultCache) { return(executeServiceDelegate.Invoke(serviceDescription)); } ServiceResultCacheKey key = BuildKey(serviceDescription); IServiceResult serviceResult; lock (serviceCallToPendingResult) { serviceResult = serviceCallToResult.Get(key); if (serviceResult != null) { return(CreateServiceResult(serviceResult)); } while (serviceCallToPendingResult.Contains(key)) { Monitor.Wait(serviceCallToPendingResult); } serviceResult = serviceCallToResult.Get(key); if (serviceResult != null) { return(CreateServiceResult(serviceResult)); } serviceCallToPendingResult.Add(key); } bool success = false; try { if (SecurityActivation != null) { serviceResult = SecurityActivation.ExecuteWithoutFiltering(new IResultingBackgroundWorkerDelegate <IServiceResult>(delegate() { return(executeServiceDelegate.Invoke(serviceDescription)); })); } else { serviceResult = executeServiceDelegate.Invoke(serviceDescription); } success = true; } finally { lock (serviceCallToPendingResult) { serviceCallToPendingResult.Remove(key); if (success) { serviceCallToResult.Put(key, serviceResult); } Monitor.PulseAll(serviceCallToPendingResult); } } return(CreateServiceResult(serviceResult)); }
static void Main() { var hashSet = new CHashSet<int>(); hashSet.Add(1); hashSet.Add(1); hashSet.Add(2); hashSet.Add(1); foreach (var item in hashSet) { Console.Write(item + " "); } Console.WriteLine(); hashSet.Remove(1); foreach (var item in hashSet) { Console.Write(item + " "); } Console.WriteLine(); var secondHashSet = new CHashSet<int>(); secondHashSet.Add(3); secondHashSet.Add(4); secondHashSet.Add(2); var unionTest = hashSet.Union(secondHashSet); foreach (var item in unionTest) { Console.Write(item + " "); } Console.WriteLine(); var intersectTest = hashSet.Intersect(secondHashSet); foreach (var item in intersectTest) { Console.Write(item + " "); } }