C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » General »

Threading Concepts in Dot Net


Posted Date: 29 Jun 2009    Resource Type: Articles    Category: General
Author: Vijayaragavan.RMember Level: Bronze    
Rating: 2 out of 52 out of 5Points: 4



Thread:
A thread is the basic unit to which the operating system allocates processor time.

Systems.Threading has all the classes related to implement threading. Any .NET application who wants to implement threading has to import this namespace.

Multi Thread:
Multi-threading forms subset of Multi-tasking. Instead of having to switch between
programs this feature switches between different parts of the same program. Example you are writing in word and at the same time word is doing a spell check in background.

Multi Tasking:
It’s a feature of modern operating systems with which we can run multiple programs at same time example Word, Excel etc.

Code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim pthread1 As New Thread(AddressOf Thread1)
Dim pthread2 As New Thread(AddressOf Thread2)
pthread1.Start()
pthread2.Start()
End Sub

Public Sub Thread1()
Dim pintcount As Integer
Dim pstr As String
pstr = “This is first thread”
Do Until pintcount > 5
lstThreadDisplay.Items.Add(pstr)
pintcount = pintcount + 1
Loop
End Sub

Public Sub Thread2()
Dim pintcount As Integer
Dim pstr As String
pstr = “This is second thread”
Do Until pintcount > 5
lstThreadDisplay.Items.Add(pstr)
pintcount = pintcount + 1
Loop
End Sub

The above sample has two methods “Thread1()” and “Thread2()” which are started in multi-threaded mode in Form load event of the sample.




Responses

Author: Prasoon Kumar    29 Jun 2009Member Level: Silver   Points : 2
Hi

Vijayaragavan.R ,

Again thanks.

Just to add to your article,

At least there is one thread associated with each process.

Even if your process/program doesn't specify a thread it

is always atleast single threaded program(most oftenly with

public void main()) .

Most fundamental aquestion here is :- WHY DO WE NEED

MULTITHREADED application/program?


Regards

Prasoon.


Author: Abhinav Dawra    29 Jun 2009Member Level: Gold   Points : 1
Thanks for this nice article on Threads.

Are AutoResetEvents and ManualResetEvents also part of threading.
Can you share some more light on them if possible?

Thanks,
Abhinav


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Threading Concepts in Dot Net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: RAID(Redundant Arrays of Inexpensive Disk) Concepts
Previous Resource: Java vs Javascript
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use