Managing a list of threads

Posted by Satanlike on Stack Overflow See other posts from Stack Overflow or by Satanlike
Published on 2010-04-20T07:51:50Z Indexed on 2010/04/20 7:53 UTC
Read the original article Hit count: 129

Filed under:
|

Hi,

I have an application (.Net 3.5) which creates threads to write something to the database so that the GUI does not block. All created threads are added to a list, so that I can wait (Thread.Join) for each thread when the application is closed (maybe not all threads are finished when the application is closed, so the app must wait for them). Because of the list I get some serious problems if there are too many threads created (OutOfMemoryException). I tried removing finished threads from the list, but somehow that didn't work. Are there better ways to manage a list of threads, so I can remove them once they are finished?

© Stack Overflow or respective owner

Related posts about c#

Related posts about threading