title: How to fix 'The current thread is not associated with the renderer's synchronization context'?
body: <p>I am trying to change change a string, being used for a title, in my blazor-server-side application. But I am having trouble getting the UI to update.</p>
  
  <p>I tried using StateHasChanged(), but that didn't work so I looked around and found that on the <a href="https://github.com/Kelsch/samples/tree/master/samples/aspnetcore/blazor/FlightFinder" rel="noreferrer">FlightFinder</a> Demo that was made, it has an OnChange event Action, so I am trying to implement that.</p>
  
  <p>It works until I try to refresh the browser, then I am hit with this error</p>
  
  <p>System.InvalidOperationException: 'The current thread is not associated with the renderer's synchronization context. Use Invoke() or InvokeAsync() to switch execution to the renderer's synchronization context when triggering rendering or modifying any state accessed during rendering.'</p>
  
  <p>This is what I have:</p>
  
  <pre><code>private string _title = "TestSite";
  public string Title =&gt; _title;
  
  public event Action OnChange;
  
  public void ChangePage(string pageName)
  {
     _title = pageName;
     NotifyStateChanged();
  }
  
  private void NotifyStateChanged(int navigationType = 0)
  {
     OnChange?.Invoke();
  }
  </code></pre>
  
  <p>All I have to do is call ChangePage("some Page Title") and it works, unless like I mentioned I try to refresh.</p>
  
  <p>I am just trying to change a string on one component that through another component, which doesn't sound all that crazy. If there is a better way to do titles or changing things from other components, I would love to hear about it.</p>
  
  <p>So, what can I do to make sure that m invoke method is on the correct thread?
  Or is there a different way to change the title that would be more effective?</p>
  
  <p>Thank you in advance!</p>