In this post we will talk about Task and what we should do when we end up with 'Task<Task<Foo>>". Let's start with a simple example. Let's asume that we have an async method. public async Task<int> DoSomethingAsync() { return await GetNumberAsync(); } We have the 'DoSomethingAsync' method that we need to call inside another task. If we call this method directly we will end up with Task<int>, but if we call this method in another Task than we will end up with... Task<int> simpleCall = DoSomethingAsync(); Task<Task<int>> complexCall = new Task<Task<int>>( async () => { return await DoSomethingAsync(); }); As we can see, to be able to call a async a method in a task we will need to add the 'async' attribute to the lambda expression (function). Because of this we will get a Task of Task (Task<Task<..>) and not a simple Task<...>. You could say that this ...
DREAMER, CRAFTER, TECHNOLOGY ENTHUSIAST, SPEAKER, TRAINER, AZURE MVP, SOLVING HARD BUSINESS PROBLEMS WITH CUTTING-EDGE TECHNOLOGY