cancel async delegetecommand

4 posts, 0 answers
  1. Hashitha
    Hashitha avatar
    2 posts
    Member since:
    Jul 2014

    Posted 18 Aug 2015 Link to this post

    hi

     in my application (application is developed using WPF c#) data is loading asynchronously to the radgridview when user clicks on refresh button. i used telerik DelegateCommand to handle the button event. and i just want to cancel the request before data is load to the grid. my UI is look like as follows (attached the screen shot.)

     

    thank you.

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 20 Aug 2015 Link to this post

    Hello,

    I guess that you have some method that asynchronously fetches the data and then passes it as an ItemsSource for RadGridView. You can try implementing hte pattern that is illustrated in the following article: Cancel an Asynchronous Method. Thus you will no be able to prevent the fetching process, but it would be easy to return empty enumerable/null if the operation has been cancelled, preventing the GridView from loading. 

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Hashitha
    Hashitha avatar
    2 posts
    Member since:
    Jul 2014

    Posted 20 Aug 2015 in reply to Ivan Ivanov Link to this post

    thank you for the reply.

     according to your reference cancellation is done inside the "foreach " loop. and that is just cancel the loop. correct me if im wrong. and isn't there any way of doing this with telerik? 

  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 21 Aug 2015 Link to this post

    Hello,

    Well, the foreach cycle serves only for the purpose of the given example. It demonstrates splitting a task to a series of smaller tasks, adding an IsCancelled check inbetween. As for our implementation of delegate command, it only guarantees that the delegate will invoke its underlying method if the conditions provided by CanExcute are successfully met. Adding cancelling logic goes in the domain of the concerte method implementation, while the delegate command pattern is the needed infrastructure to invoke the method properly.

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top