This is a migrated thread and some comments may be shown as answers.
Support for .NET 4.5 BindingOperations.EnableCollectionSynchronization
19 Answers 86 Views
This is a migrated thread and some comments may be shown as answers.
Wenrong
Top achievements
Rank 1
Wenrong asked on 10 Sep 2012, 12:08 AM
With .NET 4.5 there is the new BindingOperations.EnableCollectionSynchronization feature that would enable support for updating a ObservableCollection in the background thread, thus removing the need to dispatch to UI thread every time.

However, the current RadGridView doesn't seems to be happy with it, the first item appears fine, but then it throws the usual "wrong thread" exception for the second item.

When will the new BindingOperations.EnableCollectionSynchronization be supported in the Telerik items controls?

19 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 10 Sep 2012, 10:22 AM
Hello,

 We do not have any official .NET 4.5 builds and that is why we cannot support this feature with our current assemblies. We will do our best to provide support for BindingOperations.EnableCollectionSynchronization most probably after our Q3 2012 (Nov - Dec 2012).

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Wenrong
Top achievements
Rank 1
answered on 02 Jan 2013, 07:35 PM
Hi there,

I am using the latest internal build 1224, but EnableCollectionSynchronization still doesn't seem to work...

When will this be supported?
0
Rossen Hristov
Telerik team
answered on 03 Jan 2013, 12:53 PM
Hi,

We have made some test changes in our source code so that when the source collection is updated from another thread as in your case, we will dispatch everything to the UI thread using the UI Thread SynchronizationContext.

I am attaching a sample project with the updated binaries for testing purposes. We took the sample project from here. Can you please check it out and see whether the updated DLL's can successfully fit in your exact scenario. If you send us a small sample project for testing, we would be very grateful. We would like to test the changes that we have made in as many scenarios as possible before checking them in source control.

Looking forward to hearing from you.

Kind regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Wenrong
Top achievements
Rank 1
answered on 03 Jan 2013, 09:37 PM
Hi there,

Your example works, but it doesn't seem to be making use of the new BindingOperations.EnableCollectionSynchronization in .NET 4.5, because it still works when the line is commented out...
0
Vlad
Telerik team
answered on 04 Jan 2013, 07:40 AM
Hi,

 Yes we've decided to implement this in a bit different way no matter the framework version. 

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Wenrong
Top achievements
Rank 1
answered on 04 Jan 2013, 08:57 PM
Hi,

Thanks for the clarification. It is good that it can support .NET 4 and 4.5, but would there be any negative performance impact comparing to the default WPF implementation?
0
Vlad
Telerik team
answered on 07 Jan 2013, 07:50 AM
Hi,

 With this approach there will be no negative performance. 

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kareem Azzouny
Top achievements
Rank 1
answered on 09 Jan 2013, 02:14 PM
any ideas when this feature will be released?
0
Vlad
Telerik team
answered on 09 Jan 2013, 02:19 PM
Hi,

 This is already part of our internal build. 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kareem Azzouny
Top achievements
Rank 1
answered on 09 Jan 2013, 09:25 PM
Hi,

when will be the next production release?
0
Vlad
Telerik team
answered on 10 Jan 2013, 07:43 AM
Hello,

 The next official release is Q1 2013 (the end of February). 

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
John
Top achievements
Rank 1
answered on 20 Oct 2016, 04:27 PM

Seems like the FilterDescriptor is still expecting to be executed from the GUI thread:

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  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.DependencyObject.GetValue(DependencyProperty dp)
       at Telerik.Windows.Data.FilterDescriptor`1.get_FilteringExpression()
       at Telerik.Windows.Data.FilterDescriptor`1.CreateFilterExpression(ParameterExpression parameterExpression)
       at Telerik.Windows.Data.FilterDescriptorBase.CreateFilterExpression(Expression instance)
       at Telerik.Windows.Data.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
       at Telerik.Windows.Data.Expressions.FilterExpressionBuilder.CreateFilterExpression()
       at Telerik.Windows.Data.QueryableExtensions.Where(IQueryable source, CompositeFilterDescriptorCollection filterDescriptors)
       at Telerik.Windows.Data.QueryableCollectionView.CreateView()
       at Telerik.Windows.Data.QueryableCollectionView.get_QueryableView()
       at Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
       at Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
       at Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
       at Telerik.Windows.Data.QueryableCollectionView.InternalIndexOf(Object item)
       at Telerik.Windows.Data.QueryableCollectionView.IndexOf(Object item)
       at Telerik.Windows.Data.QueryableCollectionView.AdjustCollectionChangedIndex(Object item, Int32 index)
       at Telerik.Windows.Data.QueryableCollectionView.AdjustOldIndices(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
       at Novatech.MDLBuilder.TelerikMDIParentWindow.UpdateStatusHistory(String message, Object source, MessageLevel level) in C:\Users\john.kesselman\Source\Repos\MDLBuilder.15\CDBVisualizer\MainWindow\Messages.cs:line 578
       at Novatech.MDLBuilder.TelerikMDIParentWindow.ProcessMDLExecutionMessage(String msg, UInt32 line, MessageLevel level, String errorSource, List`1& buildErrors, Boolean& errorRunningMDL, Boolean& messageCreated) in C:\Users\john.kesselman\Source\Repos\MDLBuilder.15\CDBVisualizer\MainWindow\Messages.cs:line 435
       at Novatech.MDLBuilder.TelerikMDIParentWindow.<>c__DisplayClass14_2.<performBuild>b__4(String msg, UInt32 line, MessageLevel level) in C:\Users\john.kesselman\Source\Repos\MDLBuilder.15\CDBVisualizer\MainWindow\Messages.cs:line 176
       at MDLBuilder.BuildFacility.ModelFileBuilder.BuildModelFile(String pcmName, String fileToCheck, Action`1 logProgress, Action`3 logMessage, Action`2 visualizeProgress, Func`1 checkIfStopped, Boolean remote) in C:\Users\john.kesselman\Source\Repos\MDLBuilder.15\MDLBuilder.BuildFacility\ModelFileBuilder.cs:line 139
       at Novatech.MDLBuilder.FileConversionHelper.BuildModelFile(String name, String fileToCheck, Action`1 logProgress, Action`3 logMessage, Action`2 visualizeProgress, Func`1 checkIfStopped, Boolean remote) in C:\Users\john.kesselman\Source\Repos\MDLBuilder.15\CDBVisualizer\FileConversionHelper.cs:line 247
       at Novatech.MDLBuilder.TelerikMDIParentWindow.<>c__DisplayClass14_0.<performBuild>b__1() in C:\Users\john.kesselman\Source\Repos\MDLBuilder.15\CDBVisualizer\MainWindow\Messages.cs:line 201
       at System.Threading.Tasks.Task`1.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
  InnerException: 

 

 

The code in question adds an item to an ObservableCollection<Message> from non-GUI thread. The grid, however, has a following filter:

new FilterDescriptor<Message>()
           {
               FilteringExpression = m =>
                   (errorToggleButton.IsChecked.HasValue && errorToggleButton.IsChecked.Value && m.Level == MessageLevel.Error)
                   || (warningToggleButton.IsChecked.HasValue && warningToggleButton.IsChecked.Value && m.Level == MessageLevel.Warning)
                   || (infoToggleButton.IsChecked.HasValue && infoToggleButton.IsChecked.Value && m.Level == MessageLevel.Info)
           });

 

 

Any ideas?

0
Ivan Ivanov
Telerik team
answered on 24 Oct 2016, 10:31 AM
Hello,

There are a few different possible invocation paths when filter descriptors are concerned. This one seems to be related to CompositeFilterDescriptor. I did not manage to reproduce it on my side, but we will try to include a "blind" fix in the next internal build. We won't be able to include in this weeks SP though. Here is the public item in our issue tracking system.

Regards,
Ivan Ivanov
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
John
Top achievements
Rank 1
answered on 05 Jan 2017, 08:08 PM

WPF UI 2016.3.1024.45

 

The issue marked as resolved, but I'm getting an exception anyway, this time from a different area. The observable collection is created on the UI Thread but populated in a Task. BindingOperations.EnableCollectionSynchronization is executed on it prior to use:

 

[1] Unhandled exception System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
   at System.Windows.Threading.Dispatcher.VerifyAccess()
   at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
   at Telerik.Windows.Data.SortDescriptorBase.get_SortDirection()
   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.QueryableCollectionView.Sort(IQueryable queryable)
   at Telerik.Windows.Data.QueryableCollectionView.CreateView()
   at Telerik.Windows.Data.QueryableCollectionView.get_QueryableView()
   at Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
   at Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
   at Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
   at Telerik.Windows.Data.QueryableCollectionView.InternalIndexOf(Object item)
   at Telerik.Windows.Data.QueryableCollectionView.IndexOf(Object item)
   at Telerik.Windows.Data.QueryableCollectionView.AdjustCollectionChangedIndex(Object item, Int32 index)
   at Telerik.Windows.Data.QueryableCollectionView.AdjustOldIndices(NotifyCollectionChangedEventArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at System.Collections.ObjectModel.CollectionExtensions.AddRange[T](Collection`1 collection, IEnumerable`1 items)

0
Ivan Ivanov
Telerik team
answered on 10 Jan 2017, 04:51 PM
Hello,

It seems that this is another similar issue. I logged it in our system. I am adding 1000 telerik points to your account. You can track our progress with the issue by following this item

Regards,
Ivan Ivanov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
John
Top achievements
Rank 1
answered on 11 Mar 2019, 02:08 PM
Both the link to the ticket and the SortDescriptorCollectionExpressionBuilder problem are still broken
0
John
Top achievements
Rank 1
answered on 11 Mar 2019, 02:15 PM

Found this: https://feedback.telerik.com/wpf/1354157-gridview-cross-thread-exception-in-queryablecollectionview-sort

I guess this is the ticket. Approved now. When can we expect a resolution?

 

 

John

0
John
Top achievements
Rank 1
answered on 11 Mar 2019, 02:16 PM

https://feedback.telerik.com/wpf/1354157-gridview-cross-thread-exception-in-queryablecollectionview-sort

Any word on when it will be resolved?

0
Martin Ivanov
Telerik team
answered on 13 Mar 2019, 08:58 AM
Hello John,

I can't give you a timeframe for fixing the issue. However, I could recommend you to follow the feedback item. This way you will get notified as soon as its status changes.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Wenrong
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Wenrong
Top achievements
Rank 1
Rossen Hristov
Telerik team
Kareem Azzouny
Top achievements
Rank 1
John
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Martin Ivanov
Telerik team
Share this question
or