c# - Overcoming lazy loading of tabControls and Combobxes -


i loading few comboboxes lots of strings (one has +70,000 values) before main ui form loaded in c#. have comboboxes in separate tabpages of tabcontrol. doing when ui form shown, there no delays in showing tabs , comboboxes.

now, problem first tabpage goes , shows quickly. however, other tabpages containing other comboboxes take 10 seconds rendered , shown up.

i have tried create controls (comboboxes) using createcontrol before loading ui form , did not help. understand c# tabcontrols have called "lazy loading" behaviour. wonder how can overcome "lazy" feature comboboxes created , rendered before form shown , when change other tab pages, there no delays?

[now editted tags - winforms related.]

thanks,

i guess threading concept overcome problem. can start new thread when form loads. let thread combo box filling or ever work required.

this thread asynchronously update combo boxes. there no delay when form loads. short example of threads provided below. guess cent percent!

public class myclass {     private volatile bool _killthread;      // method called when thread started.     public void dowork()     {         while (!_killthread)         {             //do work         }      }     public void requeststop()     {         _killthread= true;     }  }  static void myfunction() {         myclassworkerobject = new myclass();         thread workerthread = new thread(workerobject.dowork);          // start thread.         workerthread.start();          while (!workerthread.isalive);              // allow worker thread work:              thread.sleep(1);          // request worker thread stop itself:         workerobject.requeststop();          //wait untill worker thread joins self main thread         workerthread.join();  } 

you find similar example on msdn had referred code there when implemented in application year back.

cheeerss!!


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -