.NET Blog

Free. Cross-platform. Open source. A developer platform for building all your apps.

Latest posts

When at last you await
Oct 24, 2011
0
0

When at last you await

Stephen Toub - MSFT
Stephen Toub - MSFT

When you start using async methods heavily, you’ll likely see a particular pattern of composition pop up from time to time.  Its structure is typically either of the form: async Task FooAsync() {     … // some initialization code without awaits      await BarAsync(…); } or of the form: async Task<T> FooAsync() {     … // some initialization code without awaits     return await BarAsync(…); } A concrete example of this might be a FlushAsync method on...

Task.Run vs Task.Factory.StartNew
Oct 24, 2011
0
2

Task.Run vs Task.Factory.StartNew

Stephen Toub - MSFT
Stephen Toub - MSFT

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 power is complexity.  You need to know when to use which overload, what scheduler to provide, and the like. And “Task.Factory.StartNew” doesn’t exactly roll off the tongue, at least not quickly enough for something that’s used in such primary scenarios as easily offloading work to back...

Large Object Heap Improvements in .NET 4.5
Oct 3, 2011
0
0

Large Object Heap Improvements in .NET 4.5

Brandon Bray
Brandon Bray

Garbage collection is one of premiere features of the .NET managed coding platform. As the platform has become more capable, we’re seeing developers allocate more and more large objects. Since large objects are managed differently than small objects, we’ve heard a lot of feedback requesting improvement. Today’s post is by Surupa Biswas and Maoni Stephens from the garbage collection feature team. -- BrandonThe CLR manages two different heaps for allocation, the small object heap (SOH) and the large object heap (LOH). Any allocation greater than or equal to 85,000 bytes goes on the LOH. Copying la...

New articles on async/await in MSDN Magazine
Oct 3, 2011
0
0

New articles on async/await in MSDN Magazine

Stephen Toub - MSFT
Stephen Toub - MSFT

The October 2011 issue of MSDN Magazine is now available online.  In it, you can find three articles about the new async/await features of C# and Visual Basic.  While the articles can stand alone, they were written with each other in mind in order to provide a 1-2-3 on-ramp into the world of asynchronous programming with these new language and library features.Here they are.  If you read them all, we recommend you read them in the following order: Enjoy!

Keeping Async Methods Alive
Oct 2, 2011
0
0

Keeping Async Methods Alive

Stephen Toub - MSFT
Stephen Toub - MSFT

Consider a type that will print out a message when it’s finalized, and that has a Dispose method which will suppress finalization: class DisplayOnFinalize : IDisposable {     public void Dispose() { GC.SuppressFinalize(this); }     ~DisplayOnFinalize() { Console.WriteLine(“Finalized”); } } Now consider a simple usage of this class: void Foo() {     var tcs = new TaskCompletionSource<bool>();     using(new DisplayOnFinalize())     {         tcs.Task.Wait();     } } Th...

Don’t Forget To Complete Your Tasks
Oct 2, 2011
3
1

Don’t Forget To Complete Your Tasks

Stephen Toub - MSFT
Stephen Toub - MSFT

“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.  If you hand one out, someone else may  wait for that task to complete before doing some subsequent action.  It doesn’t matter whether they wait synchronously (e.g. with Wait) or asynchronously (e.g. with ContinueWith or await)… that consumer is expecting the task to eventually complet...

JavaScript Reference group Dedicated Worker
Sep 30, 2011
0
0

JavaScript Reference group Dedicated Worker

Web Development Tools Microsoft
Web Development Tools Microsoft

Travis Leithead showed a video "Building responsive apps and sites with HTML5 web workers" in BUILD. When editing "Dedicated worker" JavaScript file in Visual Studio 11 Developer's Preview, we need to add the following line in the beginning of the file to get the proper JavaScript web walker IntelliSense in the editor: "Dedicated Worker" is a reference Group defined in the Tools->Options->Text Editor->JavaScript->IntelliSense->References. It contains a JavaScript file which contains all the web walker JavaScript HTML5 objects. You can then see IntelliSense, such as importScripts: Also, Int...

Task Exception Handling in .NET 4.5
Sep 28, 2011
0
3

Task Exception Handling in .NET 4.5

Stephen Toub - MSFT
Stephen Toub - MSFT

For the .NET Framework 4.5 Developer Preview, a lot of work has been done to improve the Task Parallel Library (TPL), in terms of functionality, in terms of performance, and in terms of integration with the rest of the .NET Framework.  With all of this work, we’ve strived for a very high compatibility bar, which means your applications that use TPL in .NET 4 should “just work” when they upgrade to run against .NET 4.5 (if they don’t, please let us know, as it’s something we’ll want to fix).  Even with such a high compatibility bar, however, there are a few interesting...

Updated TPL Dataflow CTP
Sep 27, 2011
0
0

Updated TPL Dataflow CTP

Stephen Toub - MSFT
Stephen Toub - MSFT

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 4.5”, System.Threading.Tasks.Dataflow.dll is part of the .NET Framework 4.5 Developer Preview released last week at the BUILD conference.  In addition to that release, however, we’ve also refreshed the standalone CTP bits available for download on the MSDN DevLabs site at https://msdn.microsoft.com/e...