Browse by Tags

Tagged Content List
  • Blog Post: C# memory model articles

    Igor Ostrovsky is one of the minds behind the parallel programming support in the .NET Framework. Igor's recently written a great set of articles for MSDN Magazine to cover " The C# Memory Model in Theory and Practice ". Part 1 is available now in the December 2012 issue , and it's a great read.
  • Blog Post: PLINQ and Int32.MaxValue

    In both .NET 4 and .NET 4.5, PLINQ supports enumerables with up to Int32.MaxValue elements.  Beyond that limit, PLINQ will throw an overflow exception.  LINQ to Objects itself has this limitation with certain query operators (such as the indexed Select operator which counts the elements processed...
  • Blog Post: New TaskCreationOptions and TaskContinuationOptions in .NET 4.5

    Astute users of the Task Parallel Library might have noticed three new options available across TaskCreationOptions and TaskContinuationOptions in .NET 4.5: DenyChildAttach, HideScheduler, and (on TaskContinuationOptions) LazyCancellation.  I wanted to take a few minutes to share more about what...
  • Blog Post: ExecutionContext vs SynchronizationContext

    I’ve been asked a few times recently various questions about ExecutionContext and SynchronizationContext, for example what the differences are between them, what it means to “flow” them, and how they relate to the new async/await keywords in C# and Visual Basic.  I thought I’d try to tackle some...
  • Blog Post: ConcurrentQueue<T> holding on to a few dequeued elements

    Since .NET 4’s release, I’ve received several questions about a peculiar behavior of ConcurrentQueue<T> having to do with memory management. With Queue<T>, List<T>, and other such data structures in the .NET Framework, when you remove an element from the collection, the collection internally...
  • 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: Should I expose synchronous wrappers for asynchronous methods?

    In a previous post Should I expose asynchronous wrappers for synchronous methods? , I discussed “async over sync,” the notion of using synchronous functionality asynchronously and the benefits that doing so may or may not yield. The other direction of “sync over async” is also interesting to explore...
  • Blog Post: Do I need to dispose of Tasks?

    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?” Summary Here’s my short answer to this question: “No.  Don’t bother disposing of your tasks.” Here’s my medium-length answer: “No.  Don’t bother disposing...
  • Blog Post: Should I expose asynchronous wrappers for synchronous methods?

    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...
  • Blog Post: Is it ok to use nested Parallel.For loops?

    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...
  • Blog Post: Are you using TPL Dataflow? We’d love to know!

    Are you using the new System.Threading.Tasks.Dataflow.dll library, either from its CTP s 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...
  • Blog Post: When “ExecuteSynchronously” doesn’t execute synchronously

    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...
  • Blog Post: FromAsync(asyncResult, …) vs FromAsync(beginMethod, …)

    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...
  • Blog Post: Building a custom GetOrAdd method for ConcurrentDictionary<TKey,TValue>

    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...
  • Blog Post: Know Thine Implicit Allocations

    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...
  • Blog Post: Await, SynchronizationContext, and Console Apps: Part 2

    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...
  • Blog Post: Implementing a SynchronizationContext.SendAsync method

    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...
  • Blog Post: FAQ on Task.Start

    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...
  • 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: Updated Async CTP

    In April, we released the Async CTP Refresh, and since then we've seen fantastic adoption of the technology. We've also seen the technology landscape evolve. Windows Phone 7.5, aka "Mango", was released. Silverlight 5 has had both a Beta and an RC release. And there have been multiple patches to Visual...
  • Blog Post: Task.Run vs Task.Factory.StartNew

    In .NET 4, Task.Factory.StartNew was the primary method for scheduling a new task.  Many overloads provided for a highly configurable mechanism, enabling setting options, passing in arbitrary state, enabling cancellation, and even controlling scheduling behaviors.  The flip side of all of this...
  • Blog Post: Don’t Forget To Complete Your Tasks

    “Don’t forget to complete your tasks.” That guidance may sound trivial and silly, but I recently saw it as a source of a bug in software written by some very smart folks, and thus thought this would be a good opportunity to remind folks of the imperative. Tasks represent a promise...
  • Blog Post: Updated TPL Dataflow CTP

    It’s been a few months since April when we last released a Community Technology Preview (CTP) of System.Threading.Tasks.Dataflow.dll, aka “TPL Dataflow”. Today for your programming pleasure, we have another update. As mentioned in “ What’s New for Parallelism in .NET...
  • 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...
Page 1 of 5 (121 items) 12345