I am learning about asynchronous programming in C#. In this article I found that for IO-Bound operations you should not use Task.Run() but I don't know how to create a task without Task.Run()... For example I want to create a custom method named GetPageCountAsync, which query database and return results. I have method GetPageCount already which query database synchronous. I don't know better way than:
private async Task<int> GetPageCountAsync()
{
return await Task.Run(() => GetPageCount());
}
How to do this without Task.Run? I found a ExecuteReaderAsync method of SqlCommand class but I wonder how is this method implemented? Without Task.Run? If so, how?