|I'm following up on my previous async question.
There are a TON of examples out there about how to consume an Async method, yet none of then actually show you what an async method signature looks like. For example, you see plenty of Entity Framework calls like
public async Task<List<Contact>> GetContactsAsync()
return await this.dbContext.Contacts.ToListAsync();
but how is ToListAsync actually defined? I'm assuming it returns a Task<list<t>>.
I came across this article, where it appears that all I need to do is return Task.FromResult<t>. Based on that, is this correct?
static void Main(string args)
private async static void Test()
var results = await GetSomeData();
private static Task GetSomeData()
int x = 0;
for (; x (x);
When I run this, it does not appear to run async. The console output is:
with a long pause at the call to GetSomeData(). I expected the Test method to return right away, and then, when GetSomeData completes, I would see the results.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 7-Oct-21 17:25pm.