private async Task UnlockRegistryAsync(IFileOperationsExecuter fileOps) { if (this.LockToken == null) { return; } var fileName = fileOps.CombinePath(this.RegistryRoot, ".lock"); if (!await fileOps.FileExistsAsync(fileName).ConfigureAwait(false)) { return; } string token; using (var lockStream = await fileOps.OpenFileAsync(fileName, FileMode.Open, FileAccess.Read).ConfigureAwait(false)) using (var reader = new StreamReader(lockStream, InedoLib.UTF8Encoding)) { reader.ReadLine(); token = reader.ReadLine(); } if (token == this.LockToken) { await fileOps.DeleteFileAsync(fileName).ConfigureAwait(false); } this.LockToken = null; }