title: Understanding the true behavior of the DispatcherPriority enum provided in WPF
body: <p>There is documentation with definitions on <a href="https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcherpriority(v=vs.110).aspx" rel="noreferrer">what each enum does</a>. But how am I able to demo/see this in practice? And how can I possibly know when to use which priority? </p>
  
  <p>Here's some code I have created in attempt to see how the priorty affects the ordering, and it provides me with proof that the ordering is correct (the first loop iteration will have added a SystemIdle enum to the dispatch queue), but it still got added to the string last</p>
  
  <pre><code>private void btn_Click(object sender, RoutedEventArgs e)
      {
          StringBuilder result = new StringBuilder();
          new Thread(() =&gt;
              {
  
                  var vals = Enum.GetValues(typeof(DispatcherPriority)).Cast&lt;DispatcherPriority&gt;().Where(y =&gt; y &gt;= 0).ToList();
                  vals.Reverse();
                  vals.ForEach(x =&gt;
                      { 
                          Dispatcher.BeginInvoke(new Action(() =&gt;
                          {
                              result.AppendLine(string.Format("Priority: {0} Enum:{1}", ((int)x), x.ToString()));
                          }), x);
                      });
  
  
              }).Start();
  
          ShowResultAsync(result, 2000);
      }
  
      private async void ShowResultAsync(StringBuilder s, int delay)
      {
          await Task.Delay(delay);
          MessageBox.Show(s.ToString());
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EaehN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EaehN.png" alt="enter image description here"></a></p>
  
  <p>and the output order stays the same, even when the list is reversed (added this line just after <code>vals</code> gets assigned): </p>
  
  <pre><code>vals.Reverse();
  </code></pre>
  
  <p>So once again, is there anything more I can use when determining which dispatch priority I should assign?</p>