Visual Studio Profiler输出

我写了一个执行Main()小类,然后执行A() 。 我希望Main()方法在堆栈调用的根目录上独立,因为它是我应用程序中最顶层的函数。 所做的一切都应该 Main()执行。 我编写了以下代码来测试:

 namespace ProfilerTest { class Program { static int _a; static void Main() { while (true) { A(); } } static void A() { _a += 1; } } } 

但是,Profiler调用树的输出显示A()不仅通过Main()执行,而且还在与main函数相同的级别执行。

Profiler调用树输出

我的期望(注意我从调用树中删除了最后一行):

 ProfilerTest.exe 10.333 ProfilerTest.Program.Main 10.333 ProfilerTest.Program.A 5.897 

为什么是这样? 我期待的不正确吗? 或者我是否误解了分析器结果?