<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1608433#M13500</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/667162"&gt;@QuintenKent&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've upgraded to 200.7 and the cancellation of previous identify operations works as expected.&lt;/P&gt;&lt;P&gt;However, I've got another problem that I've posted &lt;A href="https://community.esri.com/t5/net-maps-sdk-questions/slow-map-loading-and-challengehandler-delay-token/m-p/1608432#M13499" target="_self"&gt;here&lt;/A&gt; after upgrading, and I can't deploy this to the user as they should not have to wait 10 minutes before the map is loaded.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Apr 2025 12:45:22 GMT</pubDate>
    <dc:creator>BjørnarSundsbø1</dc:creator>
    <dc:date>2025-04-23T12:45:22Z</dc:date>
    <item>
      <title>200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1554243#M13075</link>
      <description>&lt;P&gt;Using ArcGIS Maps SDK for .NET 200.5, I am having some issues with IdentifyLayersAsync and cancellation token.&lt;/P&gt;&lt;P&gt;I am working on a map with a few clustered feature layers, and at certain map scales the Identify operation will be very slow when identifying the clusters. This is particularly true when having just navigated the map before performing the identify operation, while &lt;EM&gt;DrawState is &lt;EM&gt;InProgress.&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It appears that performing multiple sequential calls to this method are queued if user taps the view several times in a row and the previous Identify has not been completed. What happens next is that first call is blocking the next call, and the time the user has to wait increases for every new identify request.&lt;/P&gt;&lt;P&gt;I've used CancellationTokenSource and pass the token to the Identify method. When cancelling the token, the IdentifyLayersAsync does not appear to actually be cancelled until the last request has finished.&lt;/P&gt;&lt;P&gt;Looking at the source for GeoView, the request &lt;EM&gt;_coreReference.IdentifyLayers&amp;nbsp;method does not use the cancellation token, but&amp;nbsp; uses CoreTaskExtensions.AsTask to try to perform some cancellation that seems ineffective. As far as I can tell, Cancel registration does not work, is not called or doesn't end the native call.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I can see that AsTask is used in multiple locations of the API, and if it doesn't do the trick here, I'm guessing the same might be the case in other locations (assuming I've not missed something critical in my own code).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    private async Task&amp;lt;IReadOnlyList&amp;lt;IdentifyLayerResult&amp;gt;&amp;gt; IdentifyLayersInternal(
      Point screenPoint,
      double tolerance,
      bool returnPopupsOnly,
      long maximumResultsPerLayer,
      CancellationToken cancellationToken)
    {
      return (IReadOnlyList&amp;lt;IdentifyLayerResult&amp;gt;) new IdentifyLayerResultList(await this._coreReference.IdentifyLayers(this.TransformToDrawSurface(screenPoint), tolerance, returnPopupsOnly, (int) maximumResultsPerLayer).AsTask&amp;lt;CoreArray&amp;gt;(cancellationToken).ConfigureAwait(false));
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code to reproduce.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        private int _identifyCounter;
        private async void MapView_MapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            var currentCounter = Interlocked.Increment(ref _identifyCounter);

            if (_cancellationTokenSource != null)
            {
                await _cancellationTokenSource.CancelAsync();
                _cancellationTokenSource.Dispose();
                _cancellationTokenSource = null;
                Trace.WriteLine($"Previous token CancelAsync", $"Tapped {currentCounter}");
            }

            CancellationTokenSource source = _cancellationTokenSource = new CancellationTokenSource();

            var identifyWatch = Stopwatch.StartNew();
            try
            {
                Trace.WriteLine("Start identify", $"OnIdentify {currentCounter}");
                // Used when mapscale is less than 1 : 100.000
                var maxResultPerLayer = 12; 
                var tolerance = 15;
                await MapView.IdentifyGraphicsOverlaysAsync(e.Position, tolerance, false, maxResultPerLayer);
                await MapView.IdentifyLayersAsync(e.Position, tolerance, returnPopupsOnly: true, maxResultPerLayer, source.Token);
                identifyWatch.Stop();
            }
            catch (OperationCanceledException)
            {
                identifyWatch.Stop();
                Trace.WriteLine($"OperationCanceledException after {identifyWatch.Elapsed}", $"Tapped {currentCounter}");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
            finally
            {
                if(!source.IsCancellationRequested)
                {
                    Trace.WriteLine($"Finished after {identifyWatch.Elapsed}", $"Tapped {currentCounter}");
                }

                Interlocked.Decrement(ref _identifyCounter);
                _cancellationTokenSource?.Dispose();
                _cancellationTokenSource = null;
                source?.Dispose();
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The trace I get here is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Tapped 1: Finished after 00:00:00.1374115
OnIdentify 1: Start identify
Tapped 2: Previous token CancelAsync
OnIdentify 2: Start identify
Tapped 3: Previous token CancelAsync
OnIdentify 3: Start identify
Tapped 4: Previous token CancelAsync
OnIdentify 4: Start identify
Tapped 5: Previous token CancelAsync
OnIdentify 5: Start identify
Tapped 6: Previous token CancelAsync
OnIdentify 6: Start identify
Tapped 7: Previous token CancelAsync
OnIdentify 7: Start identify
Tapped 8: Previous token CancelAsync
OnIdentify 8: Start identify
Tapped 9: Previous token CancelAsync
OnIdentify 9: Start identify
Tapped 10: Previous token CancelAsync
OnIdentify 10: Start identify
Tapped 11: Previous token CancelAsync
OnIdentify 11: Start identify
Tapped 12: Previous token CancelAsync
OnIdentify 12: Start identify
Tapped 13: Previous token CancelAsync
OnIdentify 13: Start identify
Tapped 13: Finished after 00:00:12.8716381
Tapped 10: OperationCanceledException after 00:00:13.9292636
Tapped 11: OperationCanceledException after 00:00:13.6609924
Tapped 8: OperationCanceledException after 00:00:15.0679175
Tapped 2: OperationCanceledException after 00:00:18.1325766
Tapped 3: OperationCanceledException after 00:00:17.7673405
Tapped 9: OperationCanceledException after 00:00:14.6338782
Tapped 6: OperationCanceledException after 00:00:16.2799953
Tapped 12: OperationCanceledException after 00:00:13.5238723
Tapped 5: OperationCanceledException after 00:00:16.7167265
Tapped 4: OperationCanceledException after 00:00:17.4615539
Tapped 1: OperationCanceledException after 00:00:18.7209363
Tapped 7: OperationCanceledException after 00:00:15.8465043&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the cancellation worked properly, I would have expected the OperationCancelledException before each Start identify log statement, and the elapsed to not be insane&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I will update the task with a sample webmap when my team has been able to extract the necessary data for public publishing, but hopefully there is enough information to go on here&lt;/P&gt;&lt;P&gt;Is there something that I am missing, or is there a bug going on here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 22:45:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1554243#M13075</guid>
      <dc:creator>BjørnarSundsbø1</dc:creator>
      <dc:date>2024-11-01T22:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync cancellation token and blocking call</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1554252#M13077</link>
      <description>&lt;P&gt;I've attached animation of the output of the trace. On bad tests this can accumulate up to an elapsed time of over a minute if I'm impatient enough to be aggressive with clicking&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IdentifyQueue.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/118564iC3AE37D022D2A096/image-size/medium?v=v2&amp;amp;px=400" role="button" title="IdentifyQueue.gif" alt="IdentifyQueue.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 14:26:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1554252#M13077</guid>
      <dc:creator>BjørnarSundsbø1</dc:creator>
      <dc:date>2024-10-31T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync cancellation token and blocking call</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1554649#M13079</link>
      <description>&lt;P&gt;I can reproduce the issue in this application. Zoom in/out, click clusters/features with high frequency, and the "Concurrent identify count" on the screen will increase and the trace can be seen in the output window&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BjrnarSundsb1_0-1730466785812.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/118653i3560C142491A92FA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BjrnarSundsb1_0-1730466785812.png" alt="BjrnarSundsb1_0-1730466785812.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;This application can also reproduce an issue where the whole application deadlocks and remains frozen, unresponsive to any input, task manager termination or the debugger being able to pause to see where the freeze occurs.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;In a different scenario where I had identify on mouse move, the above issue would occur when IdentifyLayer/IdentifyOverlay happens when DrawState was InProgress. For the tooltip I could disable the feature if map has not finished drawing.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;For identify through click would confuse the user with "nothing happening", but is of course a work-around to keep the application from crashing/freezing.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The sample can also replicate a binding error in the Toolkit like this:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'Esri.ArcGISRuntime.Mapping.Popups.FieldsPopupElement' and 'Esri.ArcGISRuntime.Mapping.Popups.AttachmentsPopupElement'. Consider using Converter property of Binding.
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property. FieldsPopupElement:'Esri.ArcGISRuntime.Mapping.Popups.FieldsPopupElement' BindingExpression:Path=; DataItem='FieldsPopupElement' (HashCode=35307962); target element is 'FieldsPopupElementView' (Name=''); target property is 'Element' (type 'AttachmentsPopupElement')&lt;/LI-CODE&gt;&lt;P&gt;As a side note, I can occasionally get an NullReferenceException with the CancellationTokenSource if I'm extremely aggressive, though I don't think that is related to the root issue, though I'd be open to be proved wrong&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 13:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1554649#M13079</guid>
      <dc:creator>BjørnarSundsbø1</dc:creator>
      <dc:date>2024-11-01T13:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1569517#M13183</link>
      <description>&lt;DIV class=""&gt;Hi, thank you for the detailed notes and sample app.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;I think the behavior you've identified here&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;I am working on a map with a few clustered feature layers, and at certain map scales the Identify operation will be very slow when identifying the clusters.&lt;/BLOCKQUOTE&gt;&lt;DIV class=""&gt;Is unfortunately an expected outcome for these reasons:&lt;/DIV&gt;&lt;UL class=""&gt;&lt;LI&gt;As you observed, this behavior is tied to draw status. In our current implementation, identify tasks can be added to an internal queue, but are only processed once draw status reaches the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Completed&amp;nbsp;&lt;/STRONG&gt;state.&lt;/LI&gt;&lt;LI&gt;When the previous identify task is canceled via&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;await _cancellationTokenSource.CancelAsync()&lt;/STRONG&gt;, the canceled&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;await MapView.IdentifyLayersAsync&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;task&amp;nbsp;&lt;/SPAN&gt;continues to block until we've reached draw complete and process identify tasks.&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;So, the behavior observed is caused by the length of time required to reach draw complete, and not by the actual number of identify requests made.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;It looks like the output you've shared backs this up too:&lt;/DIV&gt;&lt;UL class=""&gt;&lt;LI&gt;You can see that there are 13 different identify operations that get started&lt;/LI&gt;&lt;LI&gt;Based on output, you can see that each thread is blocking on the call to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;await MapView.IdentifyLayersAsync&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Then, once we reach draw complete, the most recent identify task succeeds &lt;STRONG&gt;(Tapped 13: Finished after 00:00:12.8716381)&lt;/STRONG&gt; and all previous tasks report an&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;OperationCanceledException&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;We'll look and see if there's a way that a canceled task can return sooner from the call to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;await&lt;/STRONG&gt;.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Also, for the binding errors you've identified, are you able to update the version of your toolkit from 200.5 to 200.6? I don't see this warning when using version 200.6 of the toolkit.&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Dec 2024 20:04:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1569517#M13183</guid>
      <dc:creator>QuintenKent</dc:creator>
      <dc:date>2024-12-17T20:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1569700#M13189</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/667162"&gt;@QuintenKent&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for getting back to me. I've extended the sample a little bit.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;New button for adding graphics to graphics overlays so graphics can be identified&lt;SPAN&gt;*&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Press Control key to identify on mouse move&lt;/LI&gt;&lt;LI&gt;Updated to 200.6&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;New and old discoveries (see screenshot)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when using control and mouse move, the drawstate flips between InProgress and Completed continiously&lt;/LI&gt;&lt;LI&gt;Sometimes when using control + mouse move to identify, the queue keeps increasing and is never processed&lt;/LI&gt;&lt;LI&gt;Sometimes the application crashes. I've seen that in our application in particular when identifying graphics while DrawState is InProgress. Most easily reproduced when zooming in to get map InProgress, and then keep control key down while moving the cursor to on and off a diamond symbol.&lt;/LI&gt;&lt;LI&gt;I see AsTask is used in many different areas of the application, such as Locators and FeatureService. If the cancellation/blocking can be fixed for identify, I also imagine we can have benefits in other areas of the application when it comes to cancellation.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Identify-InProgress.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/122008i9677128765A0DBC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Identify-InProgress.gif" alt="Identify-InProgress.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Updating both toolkit and SDK to 200.6 removes the binding error&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 12:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1569700#M13189</guid>
      <dc:creator>BjørnarSundsbø1</dc:creator>
      <dc:date>2024-12-18T12:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1569832#M13191</link>
      <description>&lt;DIV class=""&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/386906"&gt;@BjørnarSundsbø1&lt;/a&gt;, thank you for the update! Glad that moving to 200.6 fixed the binding errors you were seeing.&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;BR /&gt;For some of your other points:&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;UL class=""&gt;&lt;LI&gt;Sometimes when using control + mouse move to identify, the queue keeps increasing and is never processed&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;I was able to observe this too when running the provided sample app.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;I think this may be down to how the lifetime of the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;_cancellationTokenSource&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;member is managed. In particular, if the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;MapView.IdentifyLayersAsync&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;operation is canceled, then in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;finally&amp;nbsp;&lt;/STRONG&gt;block we still call&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;_cancellationTokenSource?.Dispose();&lt;/STRONG&gt;. I believe this has the effect of calling&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Dispose&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;on the cancellation token associated with the active, uncanceled identify Task.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;If I apply the diff below to your sample app then I no longer see this problem.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index a510c9c..63a29aa 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -113,13 +113,12 @@ public partial class MainWindow : Window, INotifyPropertyChanged
             if (!source.IsCancellationRequested)
             {
                 Trace.WriteLine($"Finished after {identifyWatch.Elapsed}", $"Tapped {currentCounter}");
+                source.Dispose();
+                _cancellationTokenSource = null;
             }

             Interlocked.Decrement(ref _identifyCounter);
             OnPropertyChanged(nameof(IdentifyCounter));
-            _cancellationTokenSource?.Dispose();
-            _cancellationTokenSource = null;
-            source.Dispose();
         }
     }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Also, I think there may be a potential bug hidden in the call to&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;await _cancellationTokenSource.CancelAsync();&lt;/STRONG&gt;. By using the async cancel method, it makes it possible for multiple identify operations to pile up if&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;CancelAsync&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;takes a while to return. I recommend replacing this with the non-async cancel method (see the diff below).&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index a510c9c..8d5e552 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -77,7 +77,7 @@ public partial class MainWindow : Window, INotifyPropertyChanged
         OnPropertyChanged(nameof(IdentifyCounter));
         if (_cancellationTokenSource != null)
         {
-            await _cancellationTokenSource.CancelAsync();
+            _cancellationTokenSource.Cancel();
             _cancellationTokenSource?.Dispose();
             _cancellationTokenSource = null;
             Trace.WriteLine($"Previous token CancelAsync", $"Tapped {currentCounter}");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;UL class=""&gt;&lt;LI&gt;I see AsTask is used in many different areas of the application, such as Locators and FeatureService. If the cancellation/blocking can be fixed for identify, I also imagine we can have benefits in other areas of the application when it comes to cancellation.&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;I do want to clarify that in this case, cancellation&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;being honored for identify operations in the Maps SDK. Due to our implementation, this cancellation is only observed (via an&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;OperationCanceledException&lt;/STRONG&gt;) after the map view reaches draw complete--which is not the intuitive expectation, and can be improved on our end.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;UL&gt;&lt;LI&gt;Sometimes the application crashes. I've seen that in our application in particular when identifying graphics while DrawState is InProgress. Most easily reproduced when zooming in to get map InProgress, and then keep control key down while moving the cursor to on and off a diamond symbol.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Finally, for the crash, would you be able to re-test with the changes to cancellation token source mentioned previously? I would be curious if they are related.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Dec 2024 16:38:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1569832#M13191</guid>
      <dc:creator>QuintenKent</dc:creator>
      <dc:date>2024-12-18T16:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1570173#M13197</link>
      <description>&lt;P&gt;I've tried the cancellation token changes which seems to have some effect on the unprocessed queue.&lt;/P&gt;&lt;P&gt;Related to the crash, it occurs from time to time, but with two symptoms. The way to reproduce is to zoom the map so DrawState is InProgress and then use Control + mouse move to build the queue.&lt;/P&gt;&lt;P&gt;The symptoms:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Queue keeps building, and then the map freezes for a while but resumes&lt;/LI&gt;&lt;LI&gt;Queue keeps building, and while processing after the freeze, the application crashes&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Identify-Freeze.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/122119i98F2F6FC9819D05B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Identify-Freeze.gif" alt="Identify-Freeze.gif" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It might beneficial to create a sample for the Tutorials section of the training materials for identify with cancellation token for others in the future. I've seen some samples where mouse move is used for map tips. Our real application has/had layers with crazy amount of data where it would take over a minute before the task was cancelled with only a few queued identify operations. The webmap was the minimum to reproduce the issue.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 14:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1570173#M13197</guid>
      <dc:creator>BjørnarSundsbø1</dc:creator>
      <dc:date>2024-12-19T14:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1573216#M13229</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/386906"&gt;@BjørnarSundsbø1&lt;/a&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, thank you for testing again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The issue you identified has been fixed and I expect it to be included in version 200.7 of the Maps SDK for .NET.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for taking the time to report this and provide a sample app!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 16:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1573216#M13229</guid>
      <dc:creator>QuintenKent</dc:creator>
      <dc:date>2025-01-07T16:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: 200.5 - IdentifyLayersAsync - cancellation token not working and application freeze</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1608433#M13500</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/667162"&gt;@QuintenKent&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've upgraded to 200.7 and the cancellation of previous identify operations works as expected.&lt;/P&gt;&lt;P&gt;However, I've got another problem that I've posted &lt;A href="https://community.esri.com/t5/net-maps-sdk-questions/slow-map-loading-and-challengehandler-delay-token/m-p/1608432#M13499" target="_self"&gt;here&lt;/A&gt; after upgrading, and I can't deploy this to the user as they should not have to wait 10 minutes before the map is loaded.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 12:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/200-5-identifylayersasync-cancellation-token-not/m-p/1608433#M13500</guid>
      <dc:creator>BjørnarSundsbø1</dc:creator>
      <dc:date>2025-04-23T12:45:22Z</dc:date>
    </item>
  </channel>
</rss>

