title: Blazor InvokeAsync vs await InvokeAsync
body: <p>Edit: for clarification, this is in a Blazor Server application</p>
  <p>I'm confused about the correct usage of InvokeAsync and updating the UI. The documentation has several usages without really explaining the reason for awaiting or not awaiting. I have also seen some contradictory threads without much to backup their reasoning.</p>
  <p>It seems wrong to make all methods async to await InvokeAsync(StateHasChanged) and I read somewhere that the reason InvokeAsync was introduced was to prevent the need for async code everywhere. But then what situations might I want to await it?</p>
  <p>awaiting:</p>
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-5.0&amp;viewFallbackFrom=aspnetcore-3.0#invoke-component-methods-externally-to-update-state" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-5.0&amp;viewFallbackFrom=aspnetcore-3.0#invoke-component-methods-externally-to-update-state</a></p>
  <p>non-await discard:</p>
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/components/rendering?view=aspnetcore-5.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/blazor/components/rendering?view=aspnetcore-5.0</a></p>
  <p>Here are some examples of different usages that I have seen, if anyone could explain or share any links with information on some of the differences between them that'd be great (thanks!)</p>
  <pre><code>public void IncrementCounter()
  {
      _counter++;
      InvokeAsync(StateHasChanged);
  }
  </code></pre>
  <pre><code>public void IncrementCounter()
  {
      InvokeAsync(() =&gt; 
      {
          _counter++;
          StateHasChanged);
      }
  }
  </code></pre>
  <pre><code>public async Task IncrementCounter()
  {
      _counter++;
      await InvokeAsync(StateHasChanged);
  }
  </code></pre>
  <pre><code>public async Task IncrementCounter()
  {
      await InvokeAsync(() =&gt;
      {
          _counter++;
          StateHasChanged();
      });
  }
  </code></pre>