public Task <TResult> OpenProjectForUpgradeableReadAsync <TResult>(ConfiguredProject project, Func <Project, TResult> action, CancellationToken cancellationToken = default) { Requires.NotNull(project, nameof(project)); Requires.NotNull(project, nameof(action)); return(_projectLockService.UpgradeableReadLockAsync(async access => { Project evaluatedProject = await access.GetProjectAsync(project, cancellationToken); // Deliberately not async to reduce the type of // code you can run while holding the lock. return action(evaluatedProject); }, cancellationToken)); }
public async Task OpenProjectXmlForUpgradeableReadAsync(UnconfiguredProject project, Func <ProjectRootElement, CancellationToken, Task> action, CancellationToken cancellationToken = default) { Requires.NotNull(project, nameof(project)); Requires.NotNull(project, nameof(action)); await _projectLockService.UpgradeableReadLockAsync(async access => { ProjectRootElement rootElement = await access.GetProjectXmlAsync(project.FullPath, cancellationToken); // Only async to let the caller upgrade to a // write lock via OpenProjectXmlForWriteAsync await action(rootElement, cancellationToken); }, cancellationToken); }