Async selector in LINQ LINQ Select usually works like this:

IEnumerable&lt;Task&lt;int&gt;&gt; res = new[] {1,2,3}.Select(async i =&gt; i);


I would like to have the following though:

IEnumerable&lt;int&gt; res = new[] {1,2,3}.Select(async i =&gt; i);


This extension method helps to get it:

static class SelectAsync
{
    public static IEnumerable&lt;TResult&gt; Select&lt;T, TResult&gt;(
        this IEnumerable&lt;T&gt; source, Func&lt;T, Task&lt;TResult&gt;&gt; selector)
    {
        return source
            .ToObservable()
            .Select(value =&gt; Observable.FromAsync(() =&gt; selector(value)))
            .Concat()
            .ToEnumerable();
    }
}


So the following is true:

public class AsyncSelect_Should
{
    [Test]
    public void Not_Block()
    {
        var src = new[] { 1, 2, 3 };
        var res = src.Select(async i =&gt; i);
        CollectionAssert.AreEqual(src, res);
    }
}


There should be something bad, really bad about it. Does it? :)
The bad part is that ToEnumerable returns an IEnumerable that blocks for each element until it is produced by the IObservable it is called on. This means that you might as well be doing:

public static IEnumerable&lt;R&gt; SelectAsync&lt;T, R&gt;(this IEnumerable&lt;T&gt; source, Func&lt;T, Task&lt;R&gt;&gt; selector)
{
    foreach (var item in source)
        yield return selector(item).Result;
}


and depending on what kind of app you're writing, this might deadlock, though I think your version of going through Rx might avoid that and be more functionality close to:

public static IEnumerable&lt;R&gt; SelectAsync&lt;T, R&gt;(this IEnumerable&lt;T&gt; source, Func&lt;T, Task&lt;R&gt;&gt; selector)
{
    foreach (var item in source)
        yield return Task.Run(() =&gt; selector(item)).Result;
}


Either way, you're blocking a Thread which is seen as a bad thing to do in the age of async/await and the TPL. It would be as bad as using Thread.Sleep with Task.Run. It is not likely to lock up your app, especially if your app is multi-threaded, but it most certainly will block a Thread on the thread pool.

I've certainly seen people get away with using Thread.Sleep with Task.Run with no real consequences, but keep in mind that it can cause issues when you scale.

As for how you might know this without being intimately familiar with Rx and the details of how its operators work? That's easy. Just know that you can never go from having an asynchronous value (Task&lt;T&gt;) to having a synchronous value (T) without awaiting (which requires that you stay in an async context) or blocking. Even Rx doesn't have enough magic to change that :)