I have an ASP.NET Core 3.1 Web API application which has a background host service where I wrote below code to simulate deadlock for the application:
public class Worker : IHostedService
{
public Task StartAsync(CancellationToken cancellationToken)
{
var a = new object();
var b = new object();
lock (a)
{
lock (b)
{
}
}
// other thread
lock (b)
{
lock (a)
{
}
}
return Task.CompletedTask;
}
}
The app is running, but the app is NOT going to deadlock or hung state, I can still hit the web api end point and result is back to me.
Will it be possible to make the running web app into deadlock or hung state, so that NONE of the API give any 200 result?
Thanks.