This is a migrated thread and some comments may be shown as answers.

cancel async delegetecommand

3 Answers 235 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hashitha
Top achievements
Rank 1
Hashitha asked on 18 Aug 2015, 08:13 AM

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.

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 20 Aug 2015, 12:43 PM
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
0
Hashitha
Top achievements
Rank 1
answered on 20 Aug 2015, 04:47 PM

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? 

0
Ivan Ivanov
Telerik team
answered on 21 Aug 2015, 10:28 AM
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
Tags
General Discussions
Asked by
Hashitha
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Hashitha
Top achievements
Rank 1
Share this question
or