If I want to load data from a database, should I use thread ?
If you have a lengthy SQL request then yes, you should use a thread so that
the user interface stay responsive while the database engine is building
your result set and the network is transfering it.
On a dual-core CPU, my application will be faster, no ?
Probably not because the thread executing the lengthy SQL request will just
wait for the database engine or the nework to return data. This task is a
I/O bound task and having multiple CPU would not enhance performance at all.
Using a thread in that case is only interesting to avoid frozing the user
interface while your application wait for data.
As I said in my previous message, you should really decouple your user
interface from your data processing. Do not messt all. Your code will be
must better and you'll be able to reuse your data processing with another
user interface, for example moving from a winform to a web application or
separating your user interface and data processing in two different machine
to build a multitier application.
Decoupling user interface and data processing will force you to better think
about your application. The end result is a better application. If you work
within a team, you can have someone work on the user interface and another
one work on the data processing.