Solved

When should I use thread?

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

808 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