async / await inside row validating event

2 posts, 0 answers
  1. David
    David avatar
    8 posts
    Member since:
    Mar 2011

    Posted 01 Dec 2016 Link to this post

    I use the gridview's row validating event to perform some validations. 

    All database methods in my persistence framework are defined async. The validation method needs database access, so it's also defined as async and returns a Task<bool>. 

    The row validating event handler awaits this validation method. If the validation fails, the isValid property is set to false.

    Everything works fine as long as there is no asynchronous database call and the code execution runs synchronously. As soon as I have real asynchronism, the grid view doesn't wait for the completion of the validating event handler anymore. It continues its internal validation and the RowEditEnded event raises - although the RowValidating event handler hasn't finished already. 

    How can I force the grid view to wait for the asynchronous validation? I know that there are some issues with events and the async/await pattern and I tried different declaration types - without success.

    Thanks for you help!

  2. Ivan Ivanov
    Ivan Ivanov avatar
    1218 posts

    Posted 06 Dec 2016 Link to this post


    The current implementation of RadGridView's validation logic executes the raising of the Validating event synchronously, so modification of this logic won't be possible unless internal changes are made. However,as INotifyDataErrorInfo supports async validation, a possible option is to pass the editing operation to complete and if errors occur, RadGridView would be notified by the ErrorsChanged event.

    Ivan Ivanov
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top