title: Why my code is throwing `The semaphore has been disposed` exception?
body: <p>In my code I am using <code>SemaphoreSlim</code> and after execution of whole <code>for</code> loop I am receiving from <code>App.g.cs</code> exception <code>The semaphore has been disposed</code>, and I can not find out why, if it is disposed only by <code>using</code> statement. Here is the code of entire method which usus:</p>
  
  <pre><code>public async Task TestHistoricalResultsAsync()
  {
      //init values and controls
      CommandStartedControlsSetup("TestResultsCommand");
  
      List&lt;Task&gt; tasks = new List&lt;Task&gt;();
      int degreeOfParallelism = 10;
      int loopCounter = 0;
      ProgressBarTick("Testing on historic data", loopCounter, Races.Count, 0);
      using (var throttler = new SemaphoreSlim(degreeOfParallelism))
      {
          //for all races in the file
          for (int i = 0; i &lt; Races.Count; i++)
          {
              int j = i;
  
              if (TaskCancellation == true)
              {
                  break;
              }
  
              await throttler.WaitAsync(TokenSource.Token);
  
              tasks.Add(Task.Run(() =&gt; //async
              {
                  try
                  {
                      CancellationToken.ThrowIfCancellationRequested();
  
                      //if the race is from 2018
                      if (Races[j].RaceDate.Year == 2018)
                      {
                          Category = Races[j].RaceCategory;
                          Distance = Races[j].RaceDistance.ToString();
  
                          //for all horses in the race
                          for (int h = 0; h &lt; Races[j].HorseList.Count; h++)
                          {
                              if (TaskCancellation == true)
                              {
                                  break;
                              }
                              CancellationToken.ThrowIfCancellationRequested();
                              HorseDataWrapper horse = new HorseDataWrapper();
                              horse = ParseHorseData(Races[j].HorseList[h], Races[j].RaceDate);
                              Races[j].HorseList[h] = horse; //get all indexes
                          }
                      }
                  }
                  catch (Exception e)
                  {
                      //
                  }
                  finally
                  {
                      loopCounter++;
  
                      ProgressBarTick("Testing on historic data", loopCounter, Races.Count, 0);
  
                      throttler.Release();
                  }
              }));
          }
      }
      try
      {
          //ThreadPool.SetMinThreads(100, 100);
          await Task.WhenAll(tasks);
      }
      catch (OperationCanceledException)
      {
          //
      }
      finally
      {
          await _dataServices.SaveRaceTestResultsAsync(Races.ToList()); //save the analysis to the file
  
          AllControlsEnabled = true;
  
          CommandCompletedControlsSetup();
  
          VisibilityCancellingMsg = Visibility.Collapsed;
      }
  }
  </code></pre>