title: async Task vs async void
body: <p>This might be a very stupid question, but I have the following lines of coding that convert RAW images to BitmapImages:</p>
  <pre><code>public async void CreateImageThumbnails(string imagePath, int imgId)
  {
      await Task.Run(() =&gt; controlCollection.Where(x =&gt; x.ImageId == imgId)
                     .FirstOrDefault()
                     .ImageSource = ThumbnailCreator.CreateThumbnail(imagePath));
  }
  </code></pre>
  <p>which calls this method <code>CreateThumbnail()</code></p>
  <pre><code>public static BitmapImage CreateThumbnail(string imagePath)
  {
      var bitmap = new BitmapImage();
  
      using (var stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
      {
          bitmap.BeginInit();
          bitmap.DecodePixelWidth = 283;
          bitmap.CacheOption = BitmapCacheOption.OnLoad;
          bitmap.StreamSource = stream;
          bitmap.EndInit();
      }
  
      bitmap.Freeze();
  
      GC.WaitForPendingFinalizers();
      GC.Collect();
  
      return bitmap;
  }
  </code></pre>
  <p>When using <code>async Void</code> instead of <code>async Task</code> in my <code>CreateImageThumbnails</code> method, my application processes the images (29 of them) about 11 seconds faster than <code>async Task</code>. Why would this be?</p>
  <p><em><strong>async void</strong></em>
  <a href="https://i.stack.imgur.com/tEQCL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tEQCL.png" alt="async void" /></a></p>
  <p><em><strong>async task</strong></em>
  <a href="https://i.stack.imgur.com/cyMjh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cyMjh.png" alt="async task" /></a></p>
  <p>The memory usage is much more using <code>void</code>, but the operation is completed <em>much</em> quicker. I have little knowledge of threading, this is why I am asking this question. Can someone please explain why this is happening?</p>
  <p>Also I have done some research on when and when not to use <code>async void</code>, but I could not find an answer to my question. (I might just not have searched very well).</p>
  <p>Thank you.</p>