c# webapi: Await Task.Run vs more granualar await
问题 I'm using async/await in WebApi Controllers according to this article: https://msdn.microsoft.com/en-us/magazine/dn802603.aspx Hava look at this simplified code in my controller: DataBaseData = await Task.Run( () => GetDataFunction() ); GetDataFunction is a function that will open a database connection, open a reader and read the data from the database. In many examples I see it handled differently. The GetDataFunction itself is awaited. And within the function every single step is awaited.