async Task<int> Main函数体中出现await关键字的编译结果

Created Diff never expires
0 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
64 lines
23 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
87 lines
namespace CSharp_AsyncLearn
namespace CSharp_AsyncLearn
{
{
internal class Program
internal class Program
{
{
[CompilerGenerated]
[CompilerGenerated]
private sealed class <Main>d__0 : IAsyncStateMachine
private sealed class <Main>d__0 : IAsyncStateMachine
{
{
public int <>1__state;
public int <>1__state;


public AsyncTaskMethodBuilder<int> <>t__builder;
public AsyncTaskMethodBuilder<int> <>t__builder;


[System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })]
[System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })]
public string[] args;
public string[] args;


private TaskAwaiter <>u__1;

private void MoveNext()
private void MoveNext()
{
{
int num = <>1__state;
int num = <>1__state;
int result;
int result;
try
try
{
{
TaskAwaiter awaiter;
if (num != 0)
{
awaiter = Task.Delay(1000).GetAwaiter();
if (!awaiter.IsCompleted)
{
num = (<>1__state = 0);
<>u__1 = awaiter;
<Main>d__0 stateMachine = this;
<>t__builder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
return;
}
}
else
{
awaiter = <>u__1;
<>u__1 = default(TaskAwaiter);
num = (<>1__state = -1);
}
awaiter.GetResult();
Console.WriteLine("111");
result = 114514;
result = 114514;
}
}
catch (Exception exception)
catch (Exception exception)
{
{
<>1__state = -2;
<>1__state = -2;
<>t__builder.SetException(exception);
<>t__builder.SetException(exception);
return;
return;
}
}
<>1__state = -2;
<>1__state = -2;
<>t__builder.SetResult(result);
<>t__builder.SetResult(result);
}
}


void IAsyncStateMachine.MoveNext()
void IAsyncStateMachine.MoveNext()
{
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
this.MoveNext();
this.MoveNext();
}
}


[DebuggerHidden]
[DebuggerHidden]
private void SetStateMachine([System.Runtime.CompilerServices.Nullable(1)] IAsyncStateMachine stateMachine)
private void SetStateMachine([System.Runtime.CompilerServices.Nullable(1)] IAsyncStateMachine stateMachine)
{
{
}
}


void IAsyncStateMachine.SetStateMachine([System.Runtime.CompilerServices.Nullable(1)] IAsyncStateMachine stateMachine)
void IAsyncStateMachine.SetStateMachine([System.Runtime.CompilerServices.Nullable(1)] IAsyncStateMachine stateMachine)
{
{
//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
this.SetStateMachine(stateMachine);
this.SetStateMachine(stateMachine);
}
}
}
}


[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.NullableContext(1)]
[AsyncStateMachine(typeof(<Main>d__0))]
[AsyncStateMachine(typeof(<Main>d__0))]
[DebuggerStepThrough]
[DebuggerStepThrough]
private static Task<int> Main(string[] args)
private static Task<int> Main(string[] args)
{
{
<Main>d__0 stateMachine = new <Main>d__0();
<Main>d__0 stateMachine = new <Main>d__0();
stateMachine.<>t__builder = AsyncTaskMethodBuilder<int>.Create();
stateMachine.<>t__builder = AsyncTaskMethodBuilder<int>.Create();
stateMachine.args = args;
stateMachine.args = args;
stateMachine.<>1__state = -1;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
return stateMachine.<>t__builder.Task;
}
}
}
}
}
}