This project is read-only.


Do not remove previous adornments within Task


According to this trace:
Exception Type: System.AggregateException
Exception Message: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
Exception Stack Trace:    at System.Threading.Tasks.TaskExceptionHolder.Finalize()
Inner Exception:
Exception Type: System.InvalidOperationException
Exception Message: The calling thread cannot access this object because a different thread owns it.
Exception Stack Trace:    at System.Windows.Threading.Dispatcher.VerifyAccess()
   at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
   at System.Windows.Controls.Panel.get_IsItemsHost()
   at System.Windows.Controls.Panel.VerifyBoundState()
   at System.Windows.Controls.Panel.get_InternalChildren()
   at Microsoft.VisualStudio.Text.Editor.Implementation.AdornmentLayer.RemoveTranslatableVisual(AdornmentAndData data)
   at Microsoft.VisualStudio.Text.Editor.Implementation.AdornmentLayer.RemoveAllAdornments()
   at IndentGuide.IndentGuideView.UpdateAdornments()
   at IndentGuide.IndentGuideView.UpdateAdornmentsCallback(Task task)
   at System.Threading.Tasks.Task.<>c__DisplayClassb.<ContinueWith>b__a(Object obj)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
we are trying to RemoveAllAdornments while not on the UI thread. I suspect this is a failure of ContinueWith(), since otherwise it would happen all the time, so we probably need to check for access and marshal to the dispatcher explicitly.
Closed Apr 8, 2013 at 5:35 AM by Zooba