Share via

UWP Application : Map Route API (MapRouteFinder.GetDrivingRouteAsync) does not respond and even no way to refresh or cancel a request

Amit Tyagi 1 Reputation point
2020-09-30T14:16:56.407+00:00

0

I am trying to draw a route on Map Control in UWP application for desktops for specific locations:

Start: { Latitude = 33.8917742, Longitude = -87.5261236 } End: { Latitude = 32.318231, Longitude = -86.902298 }

Caller API: MapRouteFinder.GetDrivingRouteAsync(startPoint, endPoint)

Issue: after I call, it never respond , It does not accept cancelation token, then I have tried to cancel manually with different approach but does not work. It seems initiator never canceled.

29443-2020-09-30-19-32-46.jpg

Please let me know in case required more details.

Please find Video and Sample Code here: https://drive.google.com/drive/folders/1_hQtOxLV8YCO-AwzKGLKIGXCfJX1hL8R?usp=sharing

Device Info:
OS Name Microsoft Windows 10 Pro
Version 10.0.18362 Build 18362
OS Manufacturer Microsoft Corporation
System Manufacturer Hewlett-Packard
System Model HP EliteBook 840 G2
System Type x64-based PC
Processor Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2601 Mhz, 2 Core(s), 4 Logical Processor(s)
BIOS Version/Date Hewlett-Packard M71 Ver. 01.28, 4/18/2019
SMBIOS Version 2.7
Embedded Controller Version 150.91
BIOS Mode Legacy
BaseBoard Manufacturer Hewlett-Packard
BaseBoard Product 2216
BaseBoard Version KBC Version 96.5B
Platform Role Mobile
Locale United States
Time Zone India Standard Time
Installed Physical Memory (RAM) 12.0 GB
Total Physical Memory 11.9 GB
Available Physical Memory 2.38 GB
Total Virtual Memory 17.1 GB
Available Virtual Memory 4.07 GB
Page File Space 5.23 GB
Kernel DMA Protection Off

Developer technologies | Universal Windows Platform (UWP)

1 answer

Sort by: Most helpful
  1. Daniele 1,996 Reputation points
    2020-10-01T06:59:32.773+00:00

    The code below works for me to handle cases when Bing Map route service does not answer in a constrained time box, let me know if it helps you too

    MapRouteFinderResult routeResult;
    using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)))
    {
        try
        {
            routeResult = await MapRouteFinder.GetDrivingRouteAsync(startPoint, endPoint).AsTask(cts.Token);
        }
        catch (TaskCanceledException)
        {
            routeResult = null;
        }
        catch (OperationCanceledException)
        {
            routeResult = null;
        }
    }
    

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.