diff options
author | therzok <marius.ungureanu@xamarin.com> | 2019-06-27 04:26:18 +0300 |
---|---|---|
committer | therzok <marius.ungureanu@xamarin.com> | 2019-07-06 22:17:15 +0300 |
commit | 5bf153161256f11d909ca58da7beeb4d3177bbf2 (patch) | |
tree | 394f059f47af93b4878f80de5cfe26eecdbb8a5e /main/src/core/MonoDevelop.Core | |
parent | 7fbef70336e0c9166130cd2ffb1426c75bf24ac6 (diff) |
Simplify some usages of CancellationTokenSource
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index 7e62055fe7..4451b84710 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -449,9 +449,7 @@ namespace MonoDevelop.Projects public Task<TargetEvaluationResult> PerformGeneratorAsync (ConfigurationSelector configuration, string generatorTarget) { return BindTask<TargetEvaluationResult> (async cancelToken => { - var cancelSource = new CancellationTokenSource (); - cancelToken.Register (() => cancelSource.Cancel ()); - + using (var cancelSource = CancellationTokenSource.CreateLinkedTokenSource (cancelToken, CancellationToken.None)) using (var monitor = new ProgressMonitor (cancelSource)) { return await this.PerformGeneratorAsync (monitor, configuration, generatorTarget); } @@ -475,9 +473,7 @@ namespace MonoDevelop.Projects return Task.FromResult (ImmutableArray<FilePath>.Empty); return BindTask<ImmutableArray<FilePath>> (cancelToken => { - var cancelSource = new CancellationTokenSource (); - cancelToken.Register (() => cancelSource.Cancel ()); - + using (var cancelSource = CancellationTokenSource.CreateLinkedTokenSource (cancelToken, CancellationToken.None)) using (var monitor = new ProgressMonitor (cancelSource)) { return GetAnalyzerFilesAsync (monitor, configuration); } @@ -501,9 +497,7 @@ namespace MonoDevelop.Projects return Task.FromResult (ImmutableArray<ProjectFile>.Empty); return BindTask<ImmutableArray<ProjectFile>> (cancelToken => { - var cancelSource = new CancellationTokenSource (); - cancelToken.Register (() => cancelSource.Cancel ()); - + using (var cancelSource = CancellationTokenSource.CreateLinkedTokenSource (cancelToken, CancellationToken.None)) using (var monitor = new ProgressMonitor (cancelSource)) { return GetSourceFilesAsync (monitor, configuration); } |