ravendb/ravendb — pull request #545 by tugberkugurlu (2014-01-13 00:30:45+00:00)
Title: applied configureawait to eleminate the deadlock problem.

I had to have the following query on the `IAsyncDocumentSession` as ASP.NET MVC child actions don't support async:

[ChildActionOnly]
public ActionResult List()
{
IEnumerable tags = _documentSession
.Query()
.ToListAsync()
.Result;

return View(tags.Select(tag => new TagModel
{
Name = tag.Name,
Slug = tag.Slug,
Count = tag.Count,
LastSeenAt = tag.LastSeenAt
}));
}

However, this call will cause a deadlock because of the reasons explained in the following articles and questions:

- [The Perfect Recipe to Shoot Yourself in The Foot - Ending up with a Deadlock Using the C# 5.0 Asynchronous Language Features][1]
- [Asynchronous .NET Client Libraries for Your HTTP API and Awareness of async/await's Bad Effects][2]
- [Best practice to call ConfigureAwait for all server-side code][3]

Hope this helps.

[1]: http://www.tugberkugurlu.com/archive/the-perfect-recipe-to-shoot-yourself-in-the-foot-ending-up-with-a-deadlock-using-the-c-sharp-5-0-asynchronous-language-features
[2]: http://www.tugberkugurlu.com/archive/asynchronousnet-client-libraries-for-your-http-api-and-awareness-of-async-await-s-bad-effects
[3]: http://stackoverflow.com/questions/13489065/best-practice-to-call-configureawait-for-all-server-side-code

Not completely sure if this pull-request completely fixes this problem (as nearly every await needs to be made against `ConfigureAwait(false)` in a library which doesn't care about the sync. context) but I just wanted to raise the problem here with this pull request.