Welcome to the Xceed Community | Help
Community Search  
More Search Options

Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

Sort Posts: Previous Next
  •  03-09-2010, 7:56 PM Post no. 26044

    Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

    Further to this post, I am attempting to run an IMultiValueConverter (applied to a Setter on a DataCell Style) on a DataGrid that contains a lot of cells without blocking the UI.

    I considered using a BackgroundWorker but this is unsuitable because the Convert function of the converter requires a return value and the UI is blocked until it gets one.

    So, I tried implementing Microsoft's DoEvents method for WPF: http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcherframe.aspx

    I also tried this similar but more comprehensive method: http://forums.msdn.microsoft.com/en-US/wpf/thread/a2988ae8-e7b8-4a62-a34f-b851aaf13886#app_doevents

    I have attached an example project demonstrating both methods, but neither are working.  When the Dispatcher.PushFrame() method is called, an exception is thrown: "Cannot perform this operation while dispatcher processing is suspended."

    Is there any way of making this work, or perhaps another method of getting the converter to run in the background or without blocking the UI while it does its work for all cells in the grid?

    For the example project, I am also encountering another error that wasn't occurring in my full application, but it seems to be related to an Xceed licensing issue - SecurityException.

    Any help with this would be greatly appreciated.

    Thanks,

    Jason


    Associate, .NET Development
    Morgan Stanley, UK
  •  03-11-2010, 12:12 PM Post no. 26072 in reply to 26044

    Re: Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

    Hi Jason,

    We wouldn't recommend doing DoEvents during a convert. We would instead recommend using TableflowView and letting the grid virtualize the items, and fix the converter as it was already explained in your other support request (case 129232).

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  03-11-2010, 7:00 PM Post no. 26082 in reply to 26072

    Re: Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

    OK, I've implemented the fix to the converter as per my other support request (http://xceed.com/CS/forums/thread/26080.aspx), but this hasn't sped things up and using TableflowView results in an error in the converter.  The DataCell.DataContext is no longer a DataRowView, it is an EmptyDataItem.

    I've attached an example project demonstrating this.  If I can't use DoEvents (not to mention it doesn't work), how can I achieve background processing of the converter across all cells for a large amount of grid data?

    Thanks,

    Jason


    Associate, .NET Development
    Morgan Stanley, UK
  •  03-15-2010, 10:25 AM Post no. 26100 in reply to 26082

    Re: Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

    Hi Jason,

    I forgot to advise you that using TableflowView, the DataContext take an intermediate state (EmptyDataItem) before going to a correct value.  Just add an if to handle this case.

    That said, are you considering the TableflowView to be slow when you move the thumb of the scroll bar? (on our side, the scroll is really smooth and rows are appearing smoothly after we stop scrolling)

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  03-16-2010, 11:45 AM Post no. 26127 in reply to 26100

    Re: Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

    Thanks, the check for EmptyDataItem resolved the issue.

    As for the performance problems, the problem isn't so much the issue of scrolling in the grid once the data is diplayed after the converter has completed running on all cells, it is the fact the UI is completely blocked while the converter is running on all the cells.  How do I keep the UI active without using a DoEvents()?


    Associate, .NET Development
    Morgan Stanley, UK
  •  03-16-2010, 3:06 PM Post no. 26133 in reply to 26127

    Re: Run IMultiValueConverter (or IValueConverter) on DataCell with lots of data without blocking UI

    Forget my previous post.  Although that points to another useful solution when using TableView, TableflowView provides a better alternative using, as you suggested, full grid virtualisation of the items.  The converter only then gets run for the items displayed in the viewport thus reducing impact on the UI.

    I had to do a little refactoring on some converter code that coloured items depending on the sequence of previous items in the grid using a static member to record information, but using the TableflowView full virtualisation is definitely a better option.  Solution attached.

    Thanks!


    Associate, .NET Development
    Morgan Stanley, UK
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.