Solved

When should I use thread?

Posted on 2011-03-24
3
336 Views
Last Modified: 2012-05-11
I am learning to create thread but still it is not clear to me where to use them and where not or when or when not.

could you give me examples with applications.

Thank you.
0
Comment
Question by:iscivanomar
3 Comments
 
LVL 27

Accepted Solution

by:
nmarun earned 125 total points
ID: 35208644
0
 
LVL 7

Assisted Solution

by:jdavistx
jdavistx earned 125 total points
ID: 35209708
Generally speaking, you want to create another thread when you need to perform a computationally expensive task, but you want to keep doing other things while that task is running.  You don't want your user to have to wait for a 10 second task to complete, when you could be letting them do something else.

.NET gives us the BackgroundWorker to perform these expensive tasks for us, and lets us continue doing other things in the application.
http://msdn.microsoft.com/en-us/library/8xs8549b.aspx

Perhaps you're doing a lot of slow file I/O, but you want to update the GUI of your application to inform the user of the current operation, file, and estimated time it's going to take, you can use a BackgroundWorker to perform these file I/O tasks and using the functionality of the BackgroundWorker you can report back status to your GUI.
0
 

Author Closing Comment

by:iscivanomar
ID: 35210756
Thank you both.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now