C#C
C#7mo ago
Jamie Brown

✅ await await ContinueWith

Can anyone help me with why I need to await the call in DoStuff() twice?
I'd normally just sequentially await the calls but thought I'd experiment with ContinueWith and this seems bizarre?
Maybe I'm missing something or just plain not using it correctly? 😅
public interface IFoo
{
    public Task<List<int>> NumberSource();
    public Task<List<int>> Double(List<int> numbers);
}

public class Bar
{
    private readonly IFoo _foo;
    // ... 
    public async Task<List<int>> DoStuff()
    {
        // Why the double await here???????
        return await await _foo.NumberSource()
            .ContinueWith(async numbers => await _foo.Double(await numbers));
    }
}
Was this page helpful?