I want to bind my combobox's data source using a binding list. The binding list contains a collection of Client instances. I managed this and it works well, but because reading from the database takes long I decided to use a task. And now once the binding list is updated via the task the combobox still has no values.
I wanted to use a normal thread at first, but struggled so switched to using a task(pretty much the same thing I guess thing I guess). So a solution using threads would be just as useful.
public partial class frmJobCreation : Form
{
public frmJobCreation()
{
InitializeComponent();
}
BindingList<Client> clients = new BindingList<Client>();
private void frmJobCreation_Load(object sender, EventArgs e)
{
cbxRtojClient.DataSource = clients;
Task.Run(() =>
{
clients = new BindingList<Client>(Client.GetClients());
});
}
}
Where Client.GetClients()
is a static method that returns List<Client>