开发者

Sane number of BackgroundWorker thread?

开发者 https://www.devze.com 2023-03-01 10:35 出处:网络
I am writing an \'Admin Console\' that accesses hMailServer via its provided COM interface. I am using Visual Basic 2010 Express. In one procedure, it scans for the whole accounts. Because it\'s a len

I am writing an 'Admin Console' that accesses hMailServer via its provided COM interface. I am using Visual Basic 2010 Express. In one procedure, it scans for the whole accounts. Because it's a lengthy procedure, I shove it into a set of BackgroundWorker threads.

First result: A maximum of 19 simultaneous threads, with 36 seconds total time.

Then I rewrote a time consuming thread initialization code segment, and managed to reduce the time required to approximately 14 seconds... but the thre开发者_运维技巧ad count now hit 330 threads!

Will that huge amount of threads be detrimental? E.g., causing out-of-memory exceptions &c. ?


I'm not a vb expert by any means, but why not limit the number of these background threads to be some multiple of the number of cores available on your machine? A huge amount of threads most likely will cause out of memory issues, or thread starvation.

0

精彩评论

暂无评论...
验证码 换一张
取 消