Browse by Tags

Tagged Content List
  • Blog Post: Implementing Then with Await

    In a post a while ago, I talked about sequential composition of asynchronous operations .  Now that we have the async/await keywords in C# and Visual Basic, such composition is trivial, and async/await are indeed the recommended way to achieve such composition with these languages. However, in that...
  • Blog Post: Async Targeting Pack for Visual Studio 11 now available for .NET 4 and Silverlight 5

    We’re happy to announce that you can now download an Async Targeting Pack for Visual Studio 11 that lets you target .NET 4 and Silverlight 5. The included DLLs address the previously discussed issue of the Visual Studio 11 Beta compilers being incompatible with the AsyncCtpLibrary* DLLs from the...
  • Blog Post: Implementing a simple ForEachAsync, part 2

    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...
  • Blog Post: Implementing a simple ForEachAsync

    Jon Skeet recently asked me how I might go about implementing the following “asynchronous ForEach” behavior: For each element in an enumerable, run a function that returns a Task<TResult> to represent the completion of processing that element. All of these functions may run asynchronously concurrently...
  • Blog Post: "The Zen of Async" at the MVP Summit 2012

    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.
  • Blog Post: Paper :: Guide to Implementing Custom TPL Dataflow Blocks

    TPL Dataflow includes a number of built-in, already-implemented blocks that target the most common scenarios. Additionally, some flexibility is provided by the set of options that may be used to tweak block behaviors. However, a developer may still choose to implement a custom block for advanced scenarios...
  • Blog Post: Coalescing CancellationTokens from Timeouts

    In the .NET Framework 4.5 Developer Preview, you’ll find that CancellationTokenSource now has timeout support built directly into its implementation. This makes it very easy to create a token that will automatically have cancellation requested after a particular time interval, e.g. public...
  • Blog Post: New in .NET 4.5: ThreadLocal.Values

    Available since .NET 4, ThreadLocal<T> is a container that holds a separate value for every thread. In practice, ThreadLocal<T> is often convenient for storing per-thread counters, resources, or partial results. As mentioned earlier on this blog, we have been thinking about adding a Values...
  • Blog Post: PLINQ Queries That Run in Parallel in .NET 4.5

    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...
  • Blog Post: Crafting a Task.TimeoutAfter Method

    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...
  • Blog Post: Exception Handling in TPL Dataflow Networks

    A “dataflow block” is represented by a class implementing the IDataflowBlock interface. The state of a dataflow block is represented by the state of its IDataflowBlock.Completion Task, which itself has a Status property. When a dataflow block is in active state, meaning that it is currently doing processing...
  • Blog Post: ConcurrentDictionary Performance Improvements in .NET 4.5

    ConcurrentDictionary is a popular concurrent data structure that was introduced in .NET 4. In the .NET 4.5 release, ConcurrentDictionary gets two performance improvements. One optimization is related to the way ConcurrentDictionary avoids torn reads and writes. To explain the background, all reference...
  • Blog Post: Using Tasks to implement the APM Pattern

    Several times recently, folks have asked how to use tasks to implement the APM pattern, otherwise known as the Asynchronous Programming Model pattern, or the IAsyncResult pattern, or the Begin/End pattern. While moving forward we encourage folks to use a Task-based pattern for exposing asynchronous operation...
  • Blog Post: Processing Sequences of Asynchronous Operations with Tasks

    Of late, I’ve seen multiple folks asking about how to use tasks to asynchronously execute a sequence of operations.  For example, given three synchronous functions: public string DoA(string input); public string DoB(string aResult); public string DoC(string bResult); you could invoke these functions...
  • Blog Post: FAQ :: TaskScheduler.UnobservedTaskException event doesn’t work?

    Recall that if exceptions thrown from Task bodies are left unobserved, they will be escalated. In .NET 4, this means that TPL will throw them on the finalizer after the Task objects are available for garbage collection. The UnobservedTaskException event on the TaskScheduler class was added as a last...
  • Blog Post: A TPL Sandbox

    In a previous post , we introduced the UnobservedTaskException event, saying that it would be useful for host-plugin scenarios where a host application should continue to execute in the presence of exceptions thrown by buggy plugins. A typical example is an Internet browser; should the entire application...
  • Blog Post: ParallelExtensionsExtras Tour - #14 - SingleItemPartitioner

    (The full set of ParallelExtensionsExtras Tour posts is available here .) In a previous ParallelExtensionsExtras Tour blog post, we talked about implementing a custom partitioner for BlockingCollection<T>. Custom partitioning is an advanced but important feature supported by both Parallel.ForEach...
  • Blog Post: ParallelExtensionsExtras Tour - #13 - AsyncCall

    (The full set of ParallelExtensionsExtras Tour posts is available here .) Producer/consumer scenarios could logically be split into two categories: those where the consumers are synchronous, blocking waiting for producers to generate data, and those where the consumers are asynchronous, such that...
  • Blog Post: ParallelExtensionsExtras Tour - #11 - ParallelDynamicInvoke

    (The full set of ParallelExtensionsExtras Tour posts is available here .) Delegates in .NET may have one or more methods in their invocation list. When you invoke a delegate, such as through the Delegate.DynamicInvoke method, the net result is that all of the methods in the invocation list get invoked...
  • Blog Post: ParallelExtensionsExtras Tour - #10 - Pipeline

    (The full set of ParallelExtensionsExtras Tour posts is available here .) Producer/consumer is a fundamental pattern employed in many parallel applications. With producer/consumer, one or more producer threads generate data that is consumed by one or more consumer threads. These consumers can themselves...
  • Blog Post: ParallelExtensionsExtras Tour - #9 - ObjectPool<T>

    (The full set of ParallelExtensionsExtras Tour posts is available here .) An object pool is a mechanism/pattern to avoid the repeated creation and destruction of objects. When code is done with an object, rather than allowing it to be garbage collected (and finalized if it’s finalizable), you put...
  • Blog Post: ParallelExtensionsExtras Tour - #8 - ReductionVariable<T>

    (The full set of ParallelExtensionsExtras Tour posts is available here .) The new .NET 4 System.Threading. ThreadLocal<T> is quite useful when you need per-thread, per-instance storage. This is in contrast to the fast ThreadStaticAttribute, which supports only per-thread storage (in .NET 4,...
  • Blog Post: ParallelExtensionsExtras Tour - #7 - Additional TaskSchedulers

    (The full set of ParallelExtensionsExtras Tour posts is available here .) In our last two ParallelExtensionsExtras blog tour posts, we’ve discussed two TaskScheduler implementations in ParallelExtensionsExtras : StaTaskScheduler and ConcurrentExclusiveInterleave. These are just 2 of more than...
  • Blog Post: ParallelExtensionsExtras Tour - #6 - ConcurrentExclusiveInterleave

    (The full set of ParallelExtensionsExtras Tour posts is available here .) As mentioned in the previous ParallelExtensionsExtras blog tour post , the Task Parallel Library (TPL) supports an extensible task scheduling mechanism, and we demonstrated how an StaTaskScheduler could be implemented that scheduled...
  • Blog Post: ParallelExtensionsExtras Tour - #5 - StaTaskScheduler

    (The full set of ParallelExtensionsExtras Tour posts is available here .) The Task Parallel Library (TPL) supports a wide array of semantics for scheduling tasks, even though it only includes two in the box (one using the ThreadPool, and one using SynchronizationContext, which exists primarily to...
Page 1 of 3 (65 items) 123