简体   繁体   English

“计划并等待运行”的任务未运行

[英]Tasks Which are “Scheduled and waiting to run” Are Not Running

I have a .net framework 4.6.1 aspnet MVC application which use to work until I updated a number of Nuget packages. 我有一个.net framework 4.6.1 aspnet MVC应用程序,该应用程序在更新多个Nuget程序包之前一直可以使用。 I have backed out of most of the key packages and the issue is not fixed. 我已经退出了大多数关键软件包,但该问题尚未解决。 Basically when my application hangs I can see a call to GetListAsync is made and never returns. 基本上,当我的应用程序挂起时,我可以看到对GetListAsync的调用,并且永远不会返回。 This is a call to a SQL server using Dapper ORM which I have gone back to a known good version and this does not fix the issue. 这是对使用Dapper ORM的SQL Server的调用,我已经回到已知的良好版本,但这不能解决问题。 Looking at the tasks list it would appear to me I have 7 awaiting tasks and 5 tasks which are ready to run but for some reason they are not being scheduled. 查看任务列表,在我看来,我有7个正在等待执行的任务和5个已准备好运行的任务,但是由于某种原因,它们没有被安排。 Looking at my worker ThreadPool I can see I have a good number of threads available and in fact this issue reproduces whenever I just start my aspnet application in dev and there is zero load on the app other than the first request. 看着我的工作者ThreadPool,我可以看到我有很多可用的线程,实际上,只要我在dev中启动aspnet应用程序,并且除了第一个请求外,该应用程序的负载为零,就会重现此问题。 Any ideas why I would have a number of Scheduled Tasks which never seem to be picked up even if I wait a long period of time? 有什么想法为什么我会有许多计划任务,即使我等待很长时间也似乎从未被执行过?

在此处输入图片说明

I faced with this situation when I had a UI thread with 当我有一个UI线程时,我遇到了这种情况

while (true)
{
   var message = await Console.In.ReadLineAsync();
   //some message processing
}

and some of another async methods have been called without await. 并且一些其他异步方法已被调用而无需等待。 And I solved this problem with two ways: 我用两种方法解决了这个问题:

Replace all async void to async Task and awaiting all async methods. 将所有异步void替换为异步Task并等待所有异步方法。 But this not solved issue with blocking UI thread 但这无法解决阻塞UI线程的问题

And just run 然后跑

    await Task.Run(async () =>
    {
        while (true)
        {
            var message = await Console.In.ReadLineAsync();
           //some message processing
        }
    }

in another thread. 在另一个线程中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM