?
Solved

When should I use thread?

Posted on 2011-03-24
3
Medium Priority
?
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

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

Assisted Solution

by:jdavistx
jdavistx earned 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

765 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