Sunday, March 01, 2015

Async Await By Example - Part 1

When I first started using C#’s async/await keywords I found it helpful to create a set of notes as I progressed.  On this post you’ll find a collection of tips and how-tos.  Hopefully others will find it useful.

Quick Tips

* Each managed thread in .NET reserves around 1MB of virtual memory
* Only a method marked async can contain the await keywords

Using NUnit to Run Test Methods

I’m using NUnit as a convenience to step through my test code.  As of v2.6.2, NUnit supports unit tests with the async keyword. 


 Beginning with NUnit 2.6.2, test methods targetting .Net 4.5 may be marked as async and NUnit will wait for the method to complete before recording the result and moving on to the next test.Async test methods may return void or Task if no value is returned, or Task<T> if a value of type T is returned.