Incorrect async/await working, Excel events in Excel Application Level Add-in

This is a long-standing issue with Office plugins: they don't provide a SynchronizationContext.

As I mention on my blog, you can work around this by ensuring you have a proper SynchronizationContext. This is a bit hacky, but it works:

private async void SearchPaneButton_Click(object sender, EventArgs e)
{
  if (SynchronizationContext.Current == null)
    SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
  await SearchAsync();
}

private async Task SearchAsync()
{
  var searchText = SearchTextBox.Text;
  SearchPaneButton.Text = "Loading…";
  var data = await new DataServiceClient().GetDataAsync(searchText);
  SearchPaneButton.Text = "Search";
  ToggleWorkbookEvents();
}

As far as the "toggling events" problem goes, I have no idea.