VS2013 Debug/Windows/Tasks: “No tasks to display”

☆樱花仙子☆ 提交于 2019-12-18 05:49:30

问题


I have Visual Studio Professional 2013 and I am debugging an application which uses async/await extensively. But when I stop at breakpoint and open Debug/Windows/Tasks window, it always says "No tasks to display."

I've made two test, in one I can see task, in another I can't (I run program, and pause it). Or I can breakpoint at waiting fro task line.

using System;
using System.Threading;
using System.Threading.Tasks;

namespace TasksDebugWindowTest
{
    class Program
    {
        static void Main(string[] args)
        {
            DoesNotWork();
        }

        static void Works()
        {
            Console.WriteLine("Starting");
            var t = Task.Factory.StartNew(() =>
            {
                Task.Delay(100 * 1000).Wait();
                Console.WriteLine("Task complete");
            });
            Console.WriteLine("Status: {0}", t.Status);
            Thread.Sleep(500);
            Console.WriteLine("Status: {0}", t.Status);
            t.Wait();
            Console.WriteLine("Done");
        }

        static void DoesNotWork()
        {
            Console.WriteLine("Starting");
            var t = Task.Delay(100 * 1000);
            t.Wait();  // **** Breakpoint here
            Console.WriteLine("Task complete");
        }
    }
}

Can anybody explain why I can see tasks in one case but not in another?


回答1:


From http://blogs.msdn.com/b/dotnet/archive/2013/06/26/announcing-the-net-framework-4-5-1-preview.aspx

In Windows 8.1 Preview, the OS has an understanding of asynchronous operations 
and the states that they can be in, which is then used by Visual Studio 2013 preview, 
in this new window [Tasks]

Given that @ScottChamberlain confirmed that Tasks window in Visual Studio works on Win8.1 and not on Win7, that seems to be the problem.



来源:https://stackoverflow.com/questions/26638563/vs2013-debug-windows-tasks-no-tasks-to-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!