0

I have a ComboBox with isEditable property true. What I am trying to do, is imitate a search box (like the searchbox from imdb.com for example). In this ComboBox I need to load a list of images and a titles. The elements from ComboBox are loaded depending on what the user typed in it.

The main problem is that my app freeze while loading the elements for ComboBox, so I thought that would be a good ideea to create a separate thread for the ComboBox, but I don't know if it's the best ideea or how could I do it.

Ambrish Pathak
  • 3,813
  • 2
  • 15
  • 30
Marius
  • 13
  • 4
  • Just create a thread for it. The question is really broad, you should read up on the topic first and then come back with a more specific question. – poke Feb 05 '17 at 11:50
  • Possible duplicate of [How to use WPF Background Worker](http://stackoverflow.com/questions/5483565/how-to-use-wpf-background-worker) – AdrianHHH Feb 05 '17 at 12:31
  • You are looking at it the wrong way. The Control stays on the main thread, you need to separate out the loading part so it can run, sans GUI, on another thread. – H H Feb 05 '17 at 12:36

1 Answers1

0

For this you can use backgroundworker which will act as a separate thread and will keep your UI responsive.

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  {
   //Some task
  }

Start the background worker like:

backgroundWorker1.RunWorkerAsync();

This will execute some logic in the background without affecting the UI

For more info you can refer this link

Ambrish Pathak
  • 3,813
  • 2
  • 15
  • 30