I apologize for sounding dense, but I swear I have read up on async/await and played with examples, but I am still stumped at simple things like why the following code is giving me error:
[HttpGet("{includeInactive}")]
public async Task<List<Torrent>> GetTorrentsAll(bool includeInactive)
{
List<Torrent> torrentsAll = await _cacheStore.GetCachedTorrentsAll();
//...potentially filter torrentsAll here
return torrentsAll;
}
So _cacheStore.GetCachedTorrentsAll()
is not an async
function. It's just a function that potentially might be taking a while in the database, so I was trying to ensure that it's not blocking. I thought that await
ing it within the async
web API was the way to go about that. But I get confusing error under the await _cacheStore.GetCachedTorrentsAll()
line that says 'List does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'List' could be found (are you missing a using directive or an assembly reference?).
I am very confused by this.