Support for .NET 4.5 BindingOperations.EnableCollectionSynchronization

14 posts, 1 answers
  1. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 09 Sep 2012 Link to this post

    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?
  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Sep 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 02 Jan 2013 Link to this post

    Hi there,

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

    When will this be supported?
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 03 Jan 2013 Link to this post

    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.

  6. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 03 Jan 2013 Link to this post

    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...
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 04 Jan 2013 Link to this post

    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.

  8. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 04 Jan 2013 Link to this post

    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?
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 07 Jan 2013 Link to this post

    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.

  10. Kareem Azzouny
    Kareem Azzouny avatar
    4 posts
    Member since:
    Feb 2008

    Posted 09 Jan 2013 Link to this post

    any ideas when this feature will be released?
  11. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Jan 2013 Link to this post

    Hi,

     This is already part of our internal build. 

    Regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  12. Kareem Azzouny
    Kareem Azzouny avatar
    4 posts
    Member since:
    Feb 2008

    Posted 09 Jan 2013 Link to this post

    Hi,

    when will be the next production release?
  13. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Jan 2013 Link to this post

    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.

  14. John
    John avatar
    17 posts
    Member since:
    Aug 2014

    Posted 20 Oct Link to this post

    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?

  15. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Oct Link to this post

    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!
Back to Top
UI for WPF is Visual Studio 2017 Ready