/// <summary> /// Enqueues a lock request for the specified resource. /// </summary> /// <param name="requestId">The unique identifier for the request.</param> /// <param name="resourceId">The resource identifier.</param> /// <param name="requestName">The name to use for identifying the request.</param> protected void RequestLock(Guid requestId, string resourceId, string requestName) { // Create a new lock request and add it to the list of all requests. LockRequest request = new LockRequest(requestId, requestName); _allRequests.TryAdd(request.RequestId, request); // Find (or create) the resource and enqueue the request. LockResource resource = GetResource(resourceId); resource.AddRequest(request); }
/// <summary> /// Enqueues a lock request for the specified resource. /// </summary> /// <param name="requestId">The unique identifier for the request.</param> /// <param name="resourceIds">The list of resource identifiers.</param> /// <param name="requestName">The name to use for identifying the request.</param> /// <exception cref="ArgumentNullException"><paramref name="resourceIds" /> is null.</exception> protected void RequestLock(Guid requestId, IEnumerable <string> resourceIds, string requestName) { if (resourceIds == null) { throw new ArgumentNullException(nameof(resourceIds)); } // Create a new lock request and add it to the list of all requests. LockRequest request = new LockRequest(requestId, requestName); _allRequests.TryAdd(request.RequestId, request); // Find (or create) each resource and enqueue the request. foreach (string resourceId in resourceIds) { LockResource resource = GetResource(resourceId); resource.AddRequest(request); } }