I am trying to understand async/await and I am wondering if both methods work identically.If not can you explain why?
public async Task
First method: async keyword gives compiler signal for generating state machine. Event if you have empty void method marked as async the compiler will generate state machine.
Second method: You are returning "hot task" - task that is already completed. This method will act like the normal method.
Btw it is good idea for second scenario to cache such tasks. For example you can create dictionary witch and return cached task. If you do that you won't allocate each time new task on the heap.