- Dev Blogs
- .NET Blog
No trial. No credit card required. Just your GitHub account.
.NET Blog
Free. Cross-platform. Open source. A developer platform for building all your apps.
Latest posts

Async/Await FAQ

From time to time, I receive questions from developers which highlight either a need for more information about the new “async” and “await” keywords in C# and Visual Basic. I’ve been cataloguing these questions, and I thought I’d take this opportunity to share my answers to them.Conceptual Overviewhttps://msdn.com/async. To call out just a few specific resources, the October 2011 issue of MSDN Magazine included a trio of articles that provided a good introduction to the topic. If you read them all, I recommend you read them in the following order: The .NET team blog also inc...

Are deadlocks still possible with await?

Developers familiar with parallel programming are also familiar with a wide range of potential problems that can occur when practicing the art. One of the most well-known issues is “deadlock,” where two or more operations are waiting on each other to complete in a manner such that none of them will be able to complete.I’ve received a few times now a question along the lines of the following: “previously I was using synchronous blocking mechanisms, and I had to be careful to avoid deadlocks… now that I’m moving to more asynchronous mechanisms, do I still need to worry abo...

Overriding Stream Asynchrony

In .NET 4.5 Beta, the Stream class provides multiple virtual methods related to reading and writing: As a developer deriving from Stream, it’s helpful to understand what the base implementations do and when you can and should override them.Read, Write, FlushThe Read, Write, and Flush methods are the core synchronous mechanisms from reading and writing from and to a stream: public abstract int Read( byte[] buffer, int offset, int count); public abstract void Write(byte[] buffer, int offset, int count); public abstract void Flush(); You must override these methods. This is...

April 2012 Update for Visual Studio 11 Beta
April 2012 Update for Visual Studio 11 Beta is available. For Visual Studio 11 Beta Ultimate, You can install it through Tools->Extension Manager: For Visual Studio 11 Express Beta for Web, you can download it directly and install: April 2012 Update for Microsoft Visual Studio 11 Beta. Due to a known issue, it won't show the update in "Visual Studio 11 Express Beta for Web" extension manager, if other versions of Visual Studio 11 Beta is not installed on the machine. The update contains a fix for the razor editor issue. Please read release notes for details.&...

Async in 4.5: Worth the Await
Developers often ask for guidance on how to write responsive user interfaces. Reading most books about the .NET Framework over the past ten years, you’ll see coverage of the asynchronous programming model which requires a lot of careful attention while coding. That’s why the async features in the latest versions of C# and Visual Basic are tremendous step forward. And language innovation like async needs a great library to bring forward the potential. In this post, Alok Shriram – a Program Manager from the .NET Base Class Library team – shows the work done in the .NET Framework to be async ready. "Performan...

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?” SummaryHere’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 of your tasks, not unless performance or scalability testing reveals that you need to dispose of them based on your usage patterns in order to meet your performance goals. If you do find a need to dispose of them, only do so when it’s eas...

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() { return Task.Run(() => Foo()); }”. Is this something you’d recommend I do in my library? My short answer to such a question is “no.” But that doesn’t make for a very good blog post. So here’s my longer, more r...

Visual Studio 11 Express Beta for Web new features
In earlier blog, we mentioned that Visual Studio 11 Express Beta for Web is available to download. Besides the common features seen in Visual Studio 2010 Web Express, it provides some new functionalities. TFS support VS11 Express Beta for Web added TFS support which including all of the TFS client features, such as source control, team explorer tool window, work item etc. It works with TFS 2010, Visual Studio 11 Beta TFS, and http://tfspreview.com/ . Unit test With VS11 Express Beta, you can create a unit test project into an existing web solution. Unit test explorer is fully functional to run...

Improving Launch Performance for Your Desktop Applications
Application performance is something we hear about all the time. It almost always falls into one of the top three issues when we aggregate all of the feedback channels from .NET developers. While performance has many characteristics, application startup time is something that everyone can easily relate to. With the .NET Framework 4.5 Beta and the “Visual Studio 11” Beta we’re now sharing with you some of the same techniques we’ve successfully used to make the .NET Framework faster. The following post was written by Ashwin Kamath, a program manager on the CLR performance team. --Brandon With every release of the ...