C#/.NET Toolbox: Creating a "Safer" Task Dispose()

added by BlackRabbitCoder
10/7/2011 9:03:09 AM

483 Views

So recently, I’ve been moving some older utility classes logic over to use the excellent .NET Task Parallel Library (TPL). This library contains, at it’s core, a class called Task which allows parallel programming without the need of working directly with threads. During this process, I wrote a few extension methods I found to be useful in dealing with tasks in an easier manner, and thought I’d share them in a few posts. Today's will discuss an extension method to make disposing a task a little bit "safer".


5 comments

codingbandit
10/7/2011 12:42:46 PM
Thanks for sharing - another useful tool for the toolbox :)

dpeterson
10/7/2011 2:30:22 PM
How do you feel about the TPL so far? Is doing something like this still better than using naked threads?

BlackRabbitCoder
10/7/2011 3:31:40 PM
@codingbandit: Thanks!

@dpeterson: I like it. It's a convenient wrapper around thread pools that makes them easier to work with in general. That said you can get more performance out of threads if you know how to code them correctly, but the TPL is a great level of abstraction on top of them.

dpeterson
10/7/2011 3:35:02 PM
Thanks for the follow up. Do you think they're ready for scenarios where performance is a concern?

vijayst
10/9/2011 3:19:19 AM
A good utility. It is something that I will keep in mind while using TPL.