Showing results for .NET 4 - .NET Blog

Dec 14, 2012
Post comments count0
Post likes count1

C# memory model articles

Stephen Toub - MSFT
Stephen Toub - MSFT

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.

.NET Parallel Programming
Nov 16, 2012
Post comments count0
Post likes count0

PLINQ and Int32.MaxValue

Stephen Toub - MSFT
Stephen Toub - MSFT

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), but PLINQ has it with more.This limitati...

.NET Parallel Programming
Sep 22, 2012
Post comments count0
Post likes count1

New TaskCreationOptions and TaskContinuationOptions in .NET 4.5

Stephen Toub - MSFT
Stephen Toub - MSFT

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 these are and why we added them.DenyChildAttachA...

.NET Parallel Programming
Jun 15, 2012
Post comments count4
Post likes count19

ExecutionContext vs SynchronizationContext

Stephen Toub - MSFT
Stephen Toub - MSFT

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 of those questions here....

.NET Parallel Programming
May 8, 2012
Post comments count0
Post likes count0

ConcurrentQueue holding on to a few dequeued elements

Stephen Toub - MSFT
Stephen Toub - MSFT

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 wipes out its reference to t...

.NET Parallel Programming
Apr 26, 2012
Post comments count0
Post likes count0

Async Targeting Pack for Visual Studio 11 now available for .NET 4 and Silverlight 5

Stephen Toub - MSFT
Stephen Toub - MSFT

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 Async CTP; with this targeting pack, you ...

.NET Parallel Programming
Apr 13, 2012
Post comments count3
Post likes count6

Should I expose synchronous wrappers for asynchronous methods?

Stephen Toub - MSFT
Stephen Toub - MSFT

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. Avoid Exposing Synchrono...

.NET Parallel Programming
Mar 25, 2012
Post comments count0
Post likes count2

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...

.NET Parallel Programming
Mar 24, 2012
Post comments count0
Post likes count3

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...

.NET Parallel Programming
Mar 14, 2012
Post comments count0
Post likes count1

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 thu...

.NET Parallel Programming