예제 #1
0
        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;
        }
예제 #2
0
        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);
        }