diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2019-06-27 03:04:14 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2019-07-07 18:22:42 +0300 |
commit | d72cb733157ac4eb7622b4a0f857a3027e0dc83f (patch) | |
tree | 4dbecff7818d6f4a2423650aff1f5c4477699e7c /main | |
parent | 0448409d5cea4c424f1d1c3184eedb600f35a325 (diff) |
[Debugger] Fix regression introduced when optimizing handlers
https://github.com/mono/monodevelop/commit/ef5ea322347547cb6d971b6097b41965312178e6 introduced a regression where we would load the children on a background thread.
That seems to race with debugger suspending/resuming. Go back to running on the UI thread. Also, fix up usage of the token source.
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs index afceba6802..1a54b30564 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs @@ -947,15 +947,20 @@ namespace MonoDevelop.Debugger } int numberOfChildren = store.IterNChildren (iter); - Task.Run (() => { + + var token = cancellationTokenSource.Token; + Runtime.RunInMainThread (() => { + if (token.IsCancellationRequested) + return Array.Empty<ObjectValue> (); + try { return value.GetRangeOfChildren (numberOfChildren - 1, 20); } catch (Exception ex) { // Note: this should only happen if someone breaks ObjectValue.GetAllChildren() LoggingService.LogError ("Failed to get ObjectValue children.", ex); - return new ObjectValue[0]; + return Array.Empty<ObjectValue> (); } - }, cancellationTokenSource.Token).ContinueWith (t => { + }).ContinueWith (t => { TreeIter it; if (disposed) return; @@ -975,7 +980,7 @@ namespace MonoDevelop.Debugger if (compact) RecalculateWidth (); enumerableLoading.Remove (value); - }, cancellationTokenSource.Token, TaskContinuationOptions.NotOnCanceled, Runtime.MainTaskScheduler).Ignore (); + }, token, TaskContinuationOptions.OnlyOnRanToCompletion, Runtime.MainTaskScheduler).Ignore (); } void RefreshRow (TreeIter iter, ObjectValue val) |