c# - 如何在 DotPeek 的帮助下查看异步状态机(底层的异步/等待)?

标签 c# .net .net-core decompiling dotpeek

我正在观看一个视频类(class),其中作者在幕后谈论了 async/await。他展示了准备好的和反编译的代码。我想从头开始做同样的事情。我的意思是,在 DotPeek 的帮助下反编译一些 C# 编译文件。所以我有以下简单的例子:

class Program
{
    public static async Task KekAsync()
    {
        Console.WriteLine("Current thread id before await {0}", Thread.CurrentThread.ManagedThreadId);
        await Task.Delay(200);
        Console.WriteLine("Current thread id after await {0}", Thread.CurrentThread.ManagedThreadId);
        await Task.Delay(200);
        Console.WriteLine("Current thread id after await again {0}", Thread.CurrentThread.ManagedThreadId);
        await Task.Delay(200);
        Console.WriteLine("Current thread id after await again and again {0}", Thread.CurrentThread.ManagedThreadId);

    }

    static async Task Main(string[] args)
    {
        await KekAsync();
    }
}

在 DotPeek 设置中,我有以下内容:

enter image description here

但我没有看到代码生成结果。我看到异步和等待。 enter image description here

DotPeek 只是向我展示了我的源代码。但我希望看到异步状态机的实现。代码生成的结果。我使用 .NET Core 3.1 和最新版本的 .NET Framework。两者都给我相同的结果。我错过了什么吗?

最佳答案

所以,答案很简单。右键单击文件 -> 反编译源

enter image description here

关于c# - 如何在 DotPeek 的帮助下查看异步状态机(底层的异步/等待)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63783101/

相关文章:

c# - 共享来自多个 Web 引用的数据类型

c# - 在这种情况下如何进行ajax?

c# - 将文本发送到另一个客户端的浏览器有哪些漏洞?

c# - 160位哈希算术运算的最高有效字节是多少?

c# - 如何将 JSON 文件读入指定值的字符串并使用 System.Text.Json?

C# 和 SQL Server 查询在大表上返回空列

c# - 如何使用 ToListAsync() 的函数

c# - 什么是 SQL Server CLR 集成生命周期?

c# - 如何在输入用户名时显示密码?

c# - 异常 : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host