Showing results for March 2012 - .NET Parallel Programming

Mar 25, 2012
0
2

Do I need to dispose of Tasks?

Stephen Toub - MSFT
Stephen Toub - MSFT

I get this question a lot: “Task implements IDisposable and exposes a Dispose method.  Does that mean I should dispose of all of my tasks?” SummaryHere’s my short answer to this question: “No.  Don’t bother disposing of your tasks.”Here’s my medium-length answer: “No.  Don&rsquo...

Parallel ExtensionsTask Parallel Library.NET 4
Mar 24, 2012
0
2

Should I expose asynchronous wrappers for synchronous methods?

Stephen Toub - MSFT
Stephen Toub - MSFT

Lately I’ve received several questions along the lines of the following, which I typically summarize as “async over sync”: In my library, I have a method “public T Foo();”.  I’m considering exposing an asynchronous method that would simply wrap the synchronous one, e.g. “public Task<T> FooAsync...

Task Parallel Library.NET 4.NET 4.5
Mar 14, 2012
0
1

Is it ok to use nested Parallel.For loops?

Stephen Toub - MSFT
Stephen Toub - MSFT

Every now and then, I get this question: “is it ok to use nested Parallel.For loops?” The short answer is “yes.”  As is often the case, the longer answer is, well, longer. Typically when folks ask this question, they’re concerned about one of two things.  First, they’re concerned that each nested loop will assume it “owns the machine” and will t...

Parallel ExtensionsTask Parallel Library.NET 4
Mar 6, 2012
0
0

Are you using TPL Dataflow? We’d love to know!

Stephen Toub - MSFT
Stephen Toub - MSFT

Are you using the new System.Threading.Tasks.Dataflow.dll library, either from its CTPs or from the .NET 4.5 Developer Preview or Beta?  We'd love to hear about it, and if you have time, what your experiences have been (good or bad).  What kind of solution are you building, and how are you using TPL Dataflow in it?  Has the library h...

Parallel ExtensionsTask Parallel Library.NET 4
Mar 5, 2012
2
2

Implementing a simple ForEachAsync, part 2

Stephen Toub - MSFT
Stephen Toub - MSFT

After my previous post, I received several emails and comments from folks asking why I chose to implement ForEachAsync the way I did.  My goal with that post wasn’t to prescribe a particular approach to iteration, but rather to answer a question I’d received… obviously, however, I didn’t provide enough background. Let ...

Parallel ExtensionsTask Parallel Library.NET 4.5
Mar 4, 2012
0
1

Implementing a simple ForEachAsync

Stephen Toub - MSFT
Stephen Toub - MSFT

Jon Skeet recently asked me how I might go about implementing the following “asynchronous ForEach” behavior: Given what we now know about SemaphoreSlim from my previous post, here’s one way to achieve this: public static Task ForEachAsync<TSource, TResult>(     this IEnumerable<TSource> ...

Parallel ExtensionsTask Parallel Library.NET 4.5
Mar 3, 2012
0
0

Visual Studio 11 Beta currently incompatible with AsyncCtpLibrary*.dll

Stephen Toub - MSFT
Stephen Toub - MSFT

The C# and Visual Basic compilers implement support for async/await by generating code that utilizes some specific types in the underlying framework.  These types include the “awaiters” used to await things (like Tasks) as well as the “builders” used in handling the lifetime of an async method’s invocation. With t...

Mar 3, 2012
0
0

“The Zen of Async” at the MVP Summit 2012

Stephen Toub - MSFT
Stephen Toub - MSFT

Thanks to everyone who attended my "The Zen of Async" presentation on Thursday at the MVP Summit.  As I've had several requests, here are the slides and code for the talk. Toub_MVPSummit2012_ZenOfAsync.zip

Parallel ExtensionsTask Parallel Library.NET 4.5