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 » .NET Framework »

Threads in c#


Posted Date: 31 Oct 2006    Resource Type: Articles    Category: .NET Framework
Author: santhosh kumarMember Level: Bronze    
Rating: 1 out of 5Points: 10



We can define Thread as an execution part of of a program. And also define Thread is an execution path that able to run simultaneously with other threads.

Execution of more than one thread is called Multy threading.

.Net support the multy threading concept. Multy threading allow to split the exicution in to slices.Each slice is exicuted in a specified time and then it change to another execution.this concept is called threading.

Advantage:
It provide high user interaction, better CPU utilization and improve the performance.

Disadvantage:

Debugging of multy threaded application can be challange becouse of the sharead resourse.
Tracing aproblem is difficult while comparing the singlethreaded application.

Example:

//first we define the Thread in main function
class threadexample
{
void main()
{
Thread thread1=new Thread(Threadstart(display));// Here we define a Thread;
//Threadstart is the system defined deligate
//and display is the user defined function

thread1.start();//the execution path will go to the display function
}

public void diasply()
{
for(int i=0;i<10;i++)
{
Console.WriteLine(i);}
}
}

We can also place the priorities to the threads in c#

eg:

thread1.Priority=ThreadPriority.heighst;

ThreadPriority is the enum defind by system.

Using Thread.Sleep(), we can sleep the thread in a specified seconds. Thread.Abort is a method that uses to exit/stop a thread.

Note:Thread is contain the System.threading namespace



Responses

Author: nikhil choudhary    01 Feb 2007Member Level: Bronze   Points : 0
it is a good article small and brief one


Author: Murugan.N    09 Apr 2007Member Level: Bronze   Points : 0
Very good your article.
You will give more article
Thank you


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

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: Session modes.
Previous Resource: Design patterns
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use