VB.NET Framework 7, how to multithread on existing user control?
-
I have about 6 user controls, each with its own GUI and code to load data from a MySQL database. Are there any tutorials or examples on how to use multithreading to load all 6 user controls on a Form when the Form is shown? Thanks in advance.
-
I have about 6 user controls, each with its own GUI and code to load data from a MySQL database. Are there any tutorials or examples on how to use multithreading to load all 6 user controls on a Form when the Form is shown? Thanks in advance.
Controls cannot be created and used on anything other than the UI (startup) thread. Your controls CAN, however, used Tasks or Threads to load data from the database, but populating the control data with the data returned from the database must be done on the UI thread. There are plenty of articles on the web about using tasks to get data. There is nothing specific to user controls that changes how that's done.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
I have about 6 user controls, each with its own GUI and code to load data from a MySQL database. Are there any tutorials or examples on how to use multithreading to load all 6 user controls on a Form when the Form is shown? Thanks in advance.
What Dave said and use ObservableCollections to have the UC's update "live".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I