.netcore webapi调试暂停

时间:2019-09-12 10:29:31

标签: asp.net-core

我有一个Web api项目,它是一个控制台应用程序,其主要外观如下

public static void Main(string[] args)
{

    // Get the current settings.
    ThreadPool.GetMinThreads(out var minWorker, out var minIOC);

    // Change the minimum number of worker threads to four, but
    // keep the old setting for minimum asynchronous I/O 
    // completion threads.
    if (ThreadPool.SetMinThreads(250, minIOC))
    {
        Logger.Info("The minimum number of threads was set successfully");
    }
    else
    {
        Logger.Error("The minimum number of threads was not changed");
        // The minimum number of threads was not changed.
    }

    BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args)
{
    return WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>().Build();
}

调试器运行并暂停时,总是会碰到以下行:

BuildWebHost(args).Run();

如何让它暂停正在执行的实际代码?

修改 在执行某些请求时,我正在按“暂停”,并且希望在暂停时看到例如对数据库的调用

1 个答案:

答案 0 :(得分:0)

在调试打开的线程窗口时(Debug-> Windows-> Threads)。一旦暂停,这些线程之一将是具有所需调用堆栈的合适工作线程。