Showing results for .NET 4 - .NET Parallel Programming

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
Feb 7, 2012
0
1

When “ExecuteSynchronously” doesn’t execute synchronously

Stephen Toub - MSFT
Stephen Toub - MSFT

When creating a task continuation with ContinueWith, developers have the opportunity to provide a TaskContinuationOptions enum value, which could include the TaskContinuationOptions.ExecuteSynchronously flag.  ExecuteSynchronously is a request for an optimization to run the continuation task on the same thread that completed the antecedent tas...

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

FromAsync(asyncResult, …) vs FromAsync(beginMethod, …)

Stephen Toub - MSFT
Stephen Toub - MSFT

The Task Parallel Library (TPL) provides a set of “FromAsync” helper methods that create a Task or a Task<TResult> to represent an invocation of an APM method pair, i.e. BeginXx / EndXx.  There are, however, two different flavors among these overloads: ones that accept an IAsyncResult “asyncResult” as the first pa...

Parallel ExtensionsTask Parallel Library.NET 4
Feb 4, 2012
0
2

Building a custom GetOrAdd method for ConcurrentDictionary

Stephen Toub - MSFT
Stephen Toub - MSFT

I was recently asked by a developer about getting some additional information out of ConcurrentDictionary<TKey,TValue>’s GetOrAdd method.  As a reminder, GetOrAdd either returns the value for a key currently in the dictionary, or if that key doesn’t have a value, it adds a value for the key as dictated by either a TValue prov...

Parallel Extensions.NET 4.NET 4.5
Feb 3, 2012
0
0

Know Thine Implicit Allocations

Stephen Toub - MSFT
Stephen Toub - MSFT

For .NET 4.5, we’ve invested quite a bit of effort into performance, and in particular for the Task Parallel Library (Joe Hoag wrote a good paper covering some of these improvements).  We focused such effort on TPL because it is a core component used in async programming and at a foundational level for many libraries and applications.&nb...

.NET 4.NET 4.5
Jan 21, 2012
0
0

Await, SynchronizationContext, and Console Apps: Part 2

Stephen Toub - MSFT
Stephen Toub - MSFT

Yesterday, I blogged about how you can implement a custom SynchronizationContext in order to pump the continuations used by async methods so that they may be processed on a single, dedicated thread.  I also highlighted that this is basically what UI frameworks like Windows Forms and Windows Presentation Foundation do with their message pumps.N...

Parallel ExtensionsTask Parallel Library.NET 4
Jan 20, 2012
0
0

Implementing a SynchronizationContext.SendAsync method

Stephen Toub - MSFT
Stephen Toub - MSFT

I recently saw two unrelated questions, the answers to which combine to form a potentially useful code snippet.The first question was about SynchronizationContext.  SynchronizationContext provides a Post method, which asynchronously schedules the supplied delegate and object state to be executed according to the SynchronizationContext’s ...

Parallel ExtensionsTask Parallel Library.NET 4
Jan 14, 2012
0
0

FAQ on Task.Start

Stephen Toub - MSFT
Stephen Toub - MSFT

Recently I’ve heard a number of folks asking about Task.Start, when and when not to use it, how it behaves,and so forth.  I thought I’d answer some of those questions here in an attempt to clarify and put to rest any misconceptions about what it is and what it does.1. Question: When can I use Task.Start?The Start instance method ma...

Parallel ExtensionsTask Parallel Library.NET 4
Nov 10, 2011
0
0

PLINQ Queries That Run in Parallel in .NET 4.5

Igor Ostrovsky - MSFT
Igor Ostrovsky - MSFT

One interesting thing to know about PLINQ is that not all queries are guaranteed to execute in parallel (See PLINQ Queries That Run Sequentially for reference). You can think of the AsParallel method as a hint to run in parallel for query shapes that it believes will be faster. By default, PLINQ prefers to use a simple sequential algorithm over a p...

Parallel Extensions.NET 4.NET 4.5
Nov 10, 2011
0
0

Crafting a Task.TimeoutAfter Method

Joe Hoag
Joe Hoag

Imagine that you have a Task handed to you by a third party, and that you would like to force this Task to complete within a specified time period. However, you cannot alter the “natural” completion path and completion state of the Task, as that may cause problems with other consumers of the Task. So you need a way to obtain a copy or “proxy” of th...

Parallel ExtensionsTask Parallel Library.NET 4