CancellationToken parameter on RouteTask methods (e.g. SolveRouteAsync)?

309
1
03-08-2023 08:16 AM
DavidSchuster
Occasional Contributor

Hello,

We have an .NET Framework application that uses the ArcGIS Maps SDK for .NET version 200.0.  The app includes functionality for routing/navigation.

We would like for the user to be able to cancel the route calculation (for example, if it's taking too long, etc).  In the tasked-based async pattern in .NET (which we are using in our app), the recommendation is to support a CancellationToken parameter on asynchronous methods so that long running tasks can be cancelled if necessary.

Would it be possible to add the CancellationToken parameter to the RouteTask methods in a future release of the ArcGIS Maps SDK? 

Do you have any recommendations on how best to handle cancellation in the meantime?  I was thinking of either letting the route solve continue to completion and then throwing away the result, or perhaps running the route solve in a separate thread and stopping that thread upon cancellation (which I'm concerned might lead to resource leaks).

DavidSchuster_0-1678291847485.png

Thank you!

David

0 Kudos
1 Reply
dotMorten_esri
Esri Notable Contributor

For now you can just throw away the result. Most of the work is done server-side, and once the request is fired off, you can't really stop the server from doing the processing. You'd only save the download of the response, which is a minimal overhead in the grand total.

0 Kudos