如何在 DotPeek 的帮助下查看异步状态机(引擎盖下的异步/等待)? [英] How I can see the Async state machine (async/await under the hood) with the help of DotPeek?

查看:20
本文介绍了如何在 DotPeek 的帮助下查看异步状态机(引擎盖下的异步/等待)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm watching a video lesson, where the author talking about async/await under the hood. He shows prepared and decompiled code. I want to do the same from scratch. I mean, decompile some C# compiled file with the help of, from example, DotPeek. So I have the following simple example:

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 设置中,我有以下内容:

In the DotPeek settings I have the following:

但是我没有看到代码生成结果.我看到异步和等待.

But I don't see code generation result. I see async and await.

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

DotPeek just shows me my source code. But I would like to see implementation of Async state machine. Result of the code generation. I used .NET Core 3.1 and the last version of .NET Framework. Both give me the same result. Am I miss something?

推荐答案

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

So, the answer is simple. Right click on the file -> Decompiled Sources

这篇关于如何在 DotPeek 的帮助下查看异步状态机(引擎盖下的异步/等待)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆