Cross-thread operation not valid using async/await in VSTO

Viewed 1513

I am getting a

Cross-thread operation not valid

... error with the code below. I thought async/await would take care this, but apparently not. Weird thing is that when I comment out textBoxUser.Enabled = false, the error disappears. Thoughts?

private async void buttonPopulate_Click(object sender, EventArgs e)
{
     textBoxUser.Enabled = false;

     await Populate(); 

     textBoxUser.Enabled = true; //error here
}
1 Answers
Related