Solved

When should I use thread?

Posted on 2011-03-24
3
335 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 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

18 Experts available now in Live!

Get 1:1 Help Now