title: Unexpected java.lang.IllegalArgumentException: Duplicate key in ArrayMap in Xamarin
body: <p>I am getting this mystery exception in my C# Xamarin code:</p>
  
  <pre><code>// startTime contains DateTime.Now set earlier in code
  //_progressNotification and _..Manager were set once earlier and are never null
  //The various Duration variables are doubles with values  &gt;=0 (totalDuration is never zero) 
  // The following code is inside var progressHandler = new Progress&lt;double&gt;(p =&gt;
      var progress = (int)Math.Round((p*video.Duration.TotalSeconds + downloadedDuration) * (100d/totalDuration));
      progress = Math.Min(progress, 100);
      progress = Math.Max(progress, 0);
      var secondsPasssed = (DateTime.Now - startTime).TotalSeconds; // For how many seconds are we downloading
      var remainingTine = (downloadedDuration + p * video.Duration.TotalSeconds) &lt;= 0 ? "??:??:??" : TimeSpan.FromSeconds((secondsPasssed * totalDuration / (p * video.Duration.TotalSeconds + downloadedDuration)) - secondsPasssed).ToString(@"hh\:mm\:ss");
      _progressNotification.SetContentText($"{i}/{totalItemsInQueue} {remainingTine}");
      _progressNotification.SetProgress(100, progress, false);
      _notificationManager.Notify(ProgressNotificationId, _progressNotification.Build()); // This line throws the exception
  </code></pre>
  
  <p>Basically, the progress method gets executed with values between 0 - 1 (p) and then some simple math is done to calculate a progress value and then a notification to show this progress is published (updated)</p>
  
  <p>It works fine most of the time, but sometimes it throws the mysterious exception mentioned above.</p>
  
  <p>I can't figure out what is causing the exception to occur.</p>