Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Last active September 11, 2019 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/5ad28acd846cc319baf079032c5f3e08 to your computer and use it in GitHub Desktop.
Save dcomartin/5ad28acd846cc319baf079032c5f3e08 to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace DetectAsync
{
public class BlockingDetectorController : Controller
{
[HttpGet("/sync-over-async")]
public string SyncOverAsyncMethod()
{
MyMethodAsync().Wait();
return "Hello World";
}
public async Task MyMethodAsync()
{
// Just doing a delay here to waiting 100ms like this method actually did something
await Task.Delay(100);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment