Threading in .Net Applications – Part 1

Threading is one of those many terms in .Net terminology or as we say Jargon which I have just heard or seen in textbooks. I myself have never used it or incorporated in any applications. I always used to think that it’s really gonna be a difficult task for me to understand it.

Hence for making this difficult task easy,blog1

I thought why not get into it and start understanding what all buzz is about. I am utilizing this space for sharing my learning process for same. Hope people like me who has no knowledge of threading, might get to learn at least basics of by the end of my journey of learning.

Lets start by the basics:

What is threading

Threading enables our code to perform concurrent (more than one) processing so that it can do more than one operation at a time.

Lets take an example from our day-to-day life: most of the people like to have their food simultaneously along with watching TV. This way the time is saved as multiple tasks are done at same time.Now lets go back to programming world:

blog2Generally in applications we have two kind of processing. One which deals with User Interaction and the other for worker processing like DB interaction, server-side validation etc.Taking advantage of threading what we can do is to have two threads in Application, one for UI and other for worker processes. So that worker threads can handle tasks other than the UI and UI thread handles work/processing related to User Interaction.

Why should I use Threading in my applications?

  • Results in application being more responsive: By running time-consuming tasks on a parallel “worker” thread, the main UI thread is free to continue processing Events that require user interaction like keyboard and mouse events.
  • Efficient utilization of Resources: Multithreading is useful when a thread is waiting for a response from another resource or application, While one thread is busy in performing one task, other threads can utilize the otherwise unused or less used resource.
  • Increased performance: improves performance of processor by parallel/simultaneous execution of operations.
  • Process multiple requests Concurrently: On a server, client requests can arrive concurrently and so need to be handled in parallel (the .NET Framework creates threads for this automatically if you use ASP.NET, WCF, Web Services, or Remoting). This can also be useful on a client (e.g., handling peer-to-peer networking — or even multiple requests from the user).
  • Simultaneous access to multiple applications: provides access to multiple applications at the same time because of quick context switching among threads.


Before we move forward with threading concepts, please look into this blog of mine which talks about some very common terms like Program, process, thread, tasks and try to understand what’s the basic difference between 4 of them.


One thought on “Threading in .Net Applications – Part 1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s