Lee's Lounge
“ In my blog I will discuss how things are going with FeedGhost as well as any other musings I might have… ”
Whilst developing the latest version of FeedGhost we needed to move search processing for new RSS articles from post-tree insertion to pre-tree insertion. Because processing articles for search can take time I created a queue that new articles got added to. A Thread Pool worker item would then process the queued items placing them on a "processed" queue, from which the primary thread would take them and add them to the feed tree:
I had a counter that got incremented and decremented when the worker method started and exited using a try / finally block. Like every conscientious programmer I debugged through the code and noticed that on program exit the counter wasn't being decremented. Further investigation in no small part helped by the CSharp Google Group led me to the fact that threads marked as Background can just cease to exist with try/finally and using blocks not completing. This may have implications if your using ThreadPool workers to do lengthy tasks that could get corrupted if they are halted in mid-flow, in which case it might be better to switch to using a thread rather than a ThreadPool worker.