Access controls on a taskpane when its backgroundworker has finished

  • Thread starter Thread starter MerlinXL
  • Start date Start date
M

MerlinXL

Guest
In my Excel VSTO I have a taskpane with a backgroundworker and a label control

When backgroundworker.Do_work starts the label.text is set to "Please Wait"

When the backgroundworker.RunWorkerCompleted fires I want to reset the label.text

but at the line

label1.text = "Completed"

it complains it is trying to access a control created on a different thread.

"Cross-thread operating not valid"

I've tried passing in the control as part of the DoWorkEventArgs but I still get the same error.

The same approach works fine on a normal Form, but for some reason it is not working on a taskpane.

Any thoughts or suggestions appreciated.

Continue reading...
 
Back
Top