0

I would like to know if an asynchronous implementation like the one I will show below generates a context switch problem.

public async  Task<JsonResult> Get() 
{
    var data = await GetDataAsync();
    return data;
}

public async Task<string> GetDataAsync() 
{
     return  await getDataWcfAsync();
}

public async Task<string> getDataWcfAsync()
{
    return  await getcfAsync();
}

I see a warning like this

I see a warning as shown in the screenshot.

What does this warning refer to?

developer
  • 15
  • 5
  • 1
    I would assume we'd need to see the rest of your code, but just a heads up, you can just return the `Task`. You don't need to `await` on those values if you don't need them in the method that generates them. For example, the first method could simply be written as so: `public Task Get() => GetDataAsync();` Actually, do that to all your methods and see if that helps. – Andy Aug 22 '20 at 18:20
  • We definitely need more information. Are you calling `Task.Run`? Where is this reporting coming from? – Paulo Morgado Aug 22 '20 at 19:39
  • hello thank you for your response the report is from leansentry.I do not use task.run the report evaluates a function very similar to the example in the query. – developer Aug 25 '20 at 20:49

0 Answers0