【问题标题】:VS2013 Debug/Windows/Tasks: "No tasks to display"VS2013 Debug/Windows/Tasks:“没有要显示的任务”
【发布时间】:2014-12-25 15:24:39
【问题描述】:

我有 Visual Studio Professional 2013,我正在调试一个广泛使用 async/await 的应用程序。但是当我停在断点并打开 Debug/Windows/Tasks 窗口时,它总是说“没有要显示的任务。”

我做了两个测试,一个我可以看到任务,另一个我不能(我运行程序,然后暂停它)。或者我可以在等待任务行处断点。

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");
        }
    }
}

谁能解释为什么我可以在一种情况下看到任务而在另一种情况下看不到?

【问题讨论】:

  • 它应该会显示出来,我创建了a simple test program,当我查看我的任务视图it shows up(此屏幕截图来自VS2013 Premium)。您可以添加一个简单的测试程序来复制问题并将其发布在您的问题as a edit 中吗?如果没有可重复的示例,您的问题可能会被关闭。
  • 感谢 Scott,添加了代码,并设法使其在一种情况下工作。
  • 你能发一张它不工作的截图吗?如果我 hit pause during the wait 或 use a breakpoint,您的“不起作用的示例”在我的机器上可以正常工作
  • 非常非常奇怪。我刚下班回家试试……我家的电脑没有显示任务。

标签: c# visual-studio-2013 task visual-studio-debugging


【解决方案1】:

来自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]

鉴于@ScottChamberlain 确认 Visual Studio 中的“任务”窗口在 Win8.1 而不是 Win7 上工作,这似乎是问题所在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    • 2011-03-14
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    相关资源
    最近更新 更多