/// <summary> /// Lock a key by name until disposed. /// </summary> public async Task <ILockObject> LockResourceAsync(string key) { // If we're running in a single instance, a simple lock by name is sufficient. // On multi instances, we need a locking implementation using a lock file. This is somewhat expensive. MultiLockObject lockObject = new MultiLockObject(key); await lockObject.LockAsync(); return((ILockObject)lockObject); }
/// <summary> /// Lock a key by name until disposed. /// </summary> public async Task <ILockObject> LockResourceAsync(string key) { key = key.Replace("\\", "++"); // turn it into a valid file name key = key.Replace("/", "++"); // turn it into a valid file name key = key.Replace(":", "++"); // turn it into a valid file name // If we're running in a single instance, a simple lock by name is sufficient. // On multi instances, we need a locking implementation using a lock file. This is somewhat expensive. MultiLockObject lockObject = new MultiLockObject(key); await lockObject.LockAsync(); return((ILockObject)lockObject); }