Threading’s C#

Threads run in parallel within a single process, to understand why tread is useful, you can imagine application where one thread can fetch data in the background,while another thread can display the data as it arrives.

When Treads are useful:

Multithreading is useful when one thread is waiting for response, another thread can take advantage of using CPU. For example your application have background action which need to wait for I/O response, if you don’t use thread, in this phase CPU will wait till you get response and continue.

Most of calculation can be done in parallel, if your application have lots of calculation depend on formula, you can use threads to control resources and also speed up your calculation (Take note that threads are not always speed up your calculation).

Another benefit of thread is in client-server application. Client request can be received concurrently by server and server can use thread to speed up respons to client.

Leave a Comment

Your email address will not be published. Required fields are marked *