I’m developing a winform application and would make a request in the database and populate my combobox asynchronously but am having problem of access control because they come from another thread, here’s the code.
this.backWorker.DoWork + = delegate
{
comboBoxUsers.DataSource = repositoryUser.SelectAll();
comboBoxUsers.ValueMember = "UserId";
comboBoxUsers.DisplayMember = "Name";
};
backWorker.RunWorkerAsync ();
I am studying about envoke but I’m having trouble getting to implement this,
I needed to do was leave the DoWork event visible progress bar and select to do this.
Only query your repository on the BackgroundWorker and return the results through the ProgressChangedEvenHandler to the UI