I think code talks clear
private void ucPerson_Load(object sender, EventArgs e)
{
person = new Person();
BackgroundWorker backgroundBinder = new BackgroundWorker();
backgroundBinder.DoWork += BindComboBoxes;
backgroundBinder.RunWorkerAsync();
}
private void BindComboBoxes(object sender, DoWorkEventArgs e)
{
cmbEducationLevel.DataSource = Program.eService.GetEducationLevels();
cmbNationality.DisplayMember = "Name";
cmbNationality.ValueMember = "NationalityID";
}
Error I get:
Cross-thread operation not valid: Control 'cmbNationality' accessed from a thread other than the thread it was created on.
What need I do to make it possible for my background-worker
's thread to access the combobox?