diff options
author | Alan McGovern <alan@xamarin.com> | 2018-09-26 14:11:59 +0300 |
---|---|---|
committer | Dominique Louis <dominique@Dominiques-MacBook-Pro-2.local> | 2018-10-09 18:39:12 +0300 |
commit | 50f5343c60e728648c5bdae3f1435d4daae4aaf2 (patch) | |
tree | 24cfcab8312ab5c5ac252eb30598aa273b3b32e7 /Xamarin.PropertyEditing | |
parent | 739146f4911322a3d547b624fe346c5fcd3529f6 (diff) |
[Core] Use `await` instead of `.Result`
This ensures that OperationCanceledExceptions are correctly propagated
in the event of asynchronous cancelation. There is also an additional
'token.ThrowIfCancellationRequested' check in case we bail out of
the while loop because our token is cancelled. In this scenario we
should cancel instead of setting our partial data.
Diffstat (limited to 'Xamarin.PropertyEditing')
-rw-r--r-- | Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs index 8397e8f..231c129 100644 --- a/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs @@ -484,12 +484,13 @@ namespace Xamarin.PropertyEditing.ViewModels tasks.Remove (results); if (list == null) { - list = results.Result; + list = await results; common = new HashSet<string> (list); } else - common.IntersectWith (results.Result); + common.IntersectWith (await results); } while (tasks.Count > 0 && !cancel.IsCancellationRequested); + cancel.ThrowIfCancellationRequested (); this.autocomplete.Reset (list.Where (common.Contains)); } catch (OperationCanceledException) { } |