I'm using the tree control from C#. Our application can fill the tree with a lot of data. Every time a user either expands an individual tree node or initiates the expand all nodes call, if any column is set to be sorted, an InvalidOperationException is thrown when Telerik's internal code is calling the "get" method of the "Column" property in the Telerik.Windows.Controls.GridView.ColumnSortDescriptor class.
The the VS debugger flags the exception in the file "c:\RadControlsSource\Controls\GridView\GridView\GridView\Sorting\ColumnSortDescriptor.cs", line 38.
Here's the exception information:
System.InvalidOperationException was unhandled by user code
Message="The calling thread cannot access this object because a different thread owns it."
Source="WindowsBase"
StackTrace:
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.Threading.DispatcherObject.VerifyAccess()
at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
at Telerik.Windows.Controls.GridView.ColumnSortDescriptor.get_Column()
at Telerik.Windows.Controls.GridView.ColumnSortDescriptor.CreateSortKeyExpression(ParameterExpression parameterExpression)
at Telerik.Windows.Data.SortDescriptorBase.CreateSortKeyExpression(Expression itemExpression)
at Telerik.Windows.Data.Expressions.SortDescriptorCollectionExpressionBuilder.Sort()
at Telerik.Windows.Data.QueryableExtensions.Sort(IQueryable source, IEnumerable`1 sortDescriptors)
at Telerik.Windows.Data.QueryableExtensions.Sort(IQueryable source, SortDescriptorCollection sortDescriptors)
at Telerik.Windows.Data.HierarchicalCollectionViewBase.get_BaseView()
at Telerik.Windows.Data.HierarchicalCollectionViewBase.CreateHierachyView(HierarchicalCollectionViewBase view)
at Telerik.Windows.Data.HierarchyItem.get_Children()
at Telerik.Windows.Data.HierarchicalCollectionViewBase.<
CreateView
>b__23(HierarchyItem h)
at Telerik.Windows.Data.EnumerableExtensions.<
SelectRecursive
>d__3`1.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Telerik.Windows.Data.HierarchicalCollectionViewBase.PopulateInternalList(IQueryable view)
at Telerik.Windows.Data.HierarchicalCollectionViewBase.<>c__DisplayClass32.<
CreateInternalList
>b__2e(Object s, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
InnerException:
I am accessing the TreeListView control from the main UI thread. When this exception happens, the state of the tree control is hosed and our Windows desktop application must be restarted. Can anyone give me a clue as to how I can avoid this problem? Thanks.