Click here to Skip to main content
15,909,539 members
Home / Discussions / C#
   

C#

 
AnswerRe: Prevent class member circular initialization? Pin
PIEBALDconsult4-Dec-10 10:00
mvePIEBALDconsult4-Dec-10 10:00 
QuestionDotNet ThreadPool not meant for long running jobs? Pin
devvvy2-Dec-10 23:51
devvvy2-Dec-10 23:51 
AnswerRe: DotNet ThreadPool not meant for long running jobs? PinPopular
Eddy Vluggen3-Dec-10 0:16
professionalEddy Vluggen3-Dec-10 0:16 
GeneralRe: DotNet ThreadPool not meant for long running jobs? Pin
Dalek Dave3-Dec-10 3:18
professionalDalek Dave3-Dec-10 3:18 
GeneralRe: DotNet ThreadPool not meant for long running jobs? Pin
Eddy Vluggen3-Dec-10 6:48
professionalEddy Vluggen3-Dec-10 6:48 
AnswerRe: DotNet ThreadPool not meant for long running jobs? Pin
Keith Barrow3-Dec-10 0:21
professionalKeith Barrow3-Dec-10 0:21 
GeneralRe: DotNet ThreadPool not meant for long running jobs? Pin
devvvy3-Dec-10 15:20
devvvy3-Dec-10 15:20 
GeneralRe: DotNet ThreadPool not meant for long running jobs? [modified] Pin
Keith Barrow3-Dec-10 21:46
professionalKeith Barrow3-Dec-10 21:46 
"Long lived" is relative (and fuzzy!), and the dev needs to achieve a balance.
Here, you would need to balance off the number of threads created in the pool against their lifespan. At some point the process will be long-lived enough that the threadpool will run out of threads. But you are likely to notice performance problems before you get to this stage (especially in a UI). This problem is allieviated (as Pete's post described) by the fact that we can spin off a fairly large number of threads per pool. Luc's point is also a good one: if you have a few long-lived processes (or I suppose if you spin off new long-lived processes at a slow rate) then the thread pool is an option: the processes won't occupy enough threads to block the addition of all of them. The threadpool might be slightly less efficient than coding the threading yourself in this case, but the loss is small enough not to be a problem in most applications, but you get the benefit of *much* neater code.
In my experience, a suck it and see approach is best for this sort of stuff, if you are still confused, you could try writing a test rig to compare the relative performance of a ThreadPool with processes of differing lengths and addition rates, against managing your own threads.

[Edit 2]
I suggest you read Luc's response, and Pete's too. This doesn't seem to be that much of a problem any more. To be honest, I haven't found any issues with it in the past - but by the time I only really had to use ThreadPools in earnest we were on version 3.0 of the framework.

GeneralThank you guys Pin
devvvy4-Dec-10 13:54
devvvy4-Dec-10 13:54 
AnswerRe: DotNet ThreadPool not meant for long running jobs? Pin
#realJSOP3-Dec-10 4:06
professional#realJSOP3-Dec-10 4:06 
AnswerRe: DotNet ThreadPool not meant for long running jobs? [modified] Pin
Luc Pattyn3-Dec-10 17:05
sitebuilderLuc Pattyn3-Dec-10 17:05 
AnswerRe: DotNet ThreadPool not meant for long running jobs? Pin
Pete O'Hanlon3-Dec-10 20:56
mvePete O'Hanlon3-Dec-10 20:56 
QuestionCorordinate problem when load the image in picture box in zoom mode Pin
Nivas822-Dec-10 22:10
Nivas822-Dec-10 22:10 
AnswerRe: Corordinate problem when load the image in picture box in zoom mode Pin
Luc Pattyn3-Dec-10 0:51
sitebuilderLuc Pattyn3-Dec-10 0:51 
QuestionNeeded to Create a Scrolling Ticker with LinkLabel Functionality Pin
honeyashu2-Dec-10 20:04
honeyashu2-Dec-10 20:04 
AnswerRe: Needed to Create a Scrolling Ticker with LinkLabel Functionality Pin
Jacob D Dixon4-Dec-10 3:23
Jacob D Dixon4-Dec-10 3:23 
QuestionListView in C#.net Pin
mathy2-Dec-10 19:52
mathy2-Dec-10 19:52 
AnswerRe: ListView in C#.net Pin
Hiren solanki2-Dec-10 19:54
Hiren solanki2-Dec-10 19:54 
AnswerRe: ListView in C#.net Pin
Sathesh Sakthivel2-Dec-10 21:24
Sathesh Sakthivel2-Dec-10 21:24 
GeneralRe: ListView in C#.net Pin
Hiren solanki2-Dec-10 21:42
Hiren solanki2-Dec-10 21:42 
GeneralRe: ListView in C#.net Pin
phil.o3-Dec-10 2:33
professionalphil.o3-Dec-10 2:33 
GeneralRe: ListView in C#.net Pin
Hiren solanki3-Dec-10 2:37
Hiren solanki3-Dec-10 2:37 
QuestionLinq in 3.0 Framework Pin
Tiger4562-Dec-10 18:57
Tiger4562-Dec-10 18:57 
AnswerRe: Linq in 3.0 Framework Pin
Hiren solanki2-Dec-10 19:21
Hiren solanki2-Dec-10 19:21 
GeneralRe: Linq in 3.0 Framework Pin
Tiger4562-Dec-10 20:50
Tiger4562-Dec-10 20:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.