private bool TryAllocateResources(ICollection<string> resourcesList, out IDisposable resourceAllocation) { resourceAllocation = null; lock (_lockObject) { if (resourcesList.Any(x => _resourcesAllocated.Contains(x))) return false; _resourcesAllocated.AddRange(resourcesList); } resourceAllocation = new CrossAppDomainDisposable(() => ReleaseResources(resourcesList)); return true; }
private bool TryAllocateResources(ICollection <string> resourcesList, out IDisposable resourceAllocation) { resourceAllocation = null; lock (_lockObject) { if (resourcesList.Any(x => _resourcesAllocated.Contains(x))) { return(false); } _resourcesAllocated.AddRange(resourcesList); } resourceAllocation = new CrossAppDomainDisposable(() => ReleaseResources(resourcesList)); return(true); }