I'm a new student and basically just got into the topic threading.
What I have to do seems rather simple. I have to make a combobox, but I need to fill it using a different thread. And thats where I ran into trouble, cause;
Additional information: Cross-thread operation not valid: Control 'ComboBox' accessed from a thread other than the thread it was created on.
So I did some research, and it seems you cant fill UI elements outside the main thread. So I'm sitting here scratching my head thinking what would be the best thing to do.
Help would be appreciated.
Oh btw, its C# and in windows forms.
public Customer()
{
InitializeComponent();
Thread red = new Thread(Fill);
red.Start();
}
public void Fill()
{
Thread.Sleep(5000);
ComboBox1.Items.Add(1);
ComboBox1.Items.Add(2);
ComboBox1.Items.Add(3);
ComboBox1.Items.Add(4);
ComboBox1.Items.Add(5);
ComboBox1.Items.Add(6);
ComboBox1.Items.Add(7);
}