Skip to content

Instantly share code, notes, and snippets.

@dgrunwald
Created April 15, 2012 13:18
Show Gist options
  • Save dgrunwald/2392756 to your computer and use it in GitHub Desktop.
Save dgrunwald/2392756 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
[CompilerGenerated]
[StructLayout(LayoutKind.Auto)]
private struct <CopyToAsyncInternal>d__2 : IAsyncStateMachine
{
public int <>1__state;
public AsyncTaskMethodBuilder <>t__builder;
public Stream <>4__this;
public Stream destination;
public int bufferSize;
public CancellationToken cancellationToken;
public byte[] <buffer>5__3;
public int <bytesRead>5__4;
private object <>t__awaiter;
private object <>t__stack;
void IAsyncStateMachine.MoveNext()
{
try
{
ConfiguredTaskAwaitable.ConfiguredTaskAwaiter configuredTaskAwaiter;
ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter configuredTaskAwaiter2;
switch (this.<>1__state)
{
case 0:
configuredTaskAwaiter = ((ConfiguredTaskAwaitable.ConfiguredTaskAwaiter[])this.<>t__awaiter)[0];
this.<>t__awaiter = null;
this.<>1__state = -1;
break;
case 1:
configuredTaskAwaiter2 = ((ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter[])this.<>t__awaiter)[0];
this.<>t__awaiter = null;
this.<>1__state = -1;
goto IL_176;
default:
this.<buffer>5__3 = new byte[this.bufferSize];
goto IL_D9;
}
IL_CA:
configuredTaskAwaiter.GetResult();
configuredTaskAwaiter = default(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter);
IL_D9:
configuredTaskAwaiter2 = this.<>4__this.ReadAsync(this.<buffer>5__3, 0, this.<buffer>5__3.Length, this.cancellationToken).ConfigureAwait(false).GetAwaiter();
if (!configuredTaskAwaiter2.IsCompleted)
{
this.<>1__state = 1;
ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter[] array;
(array = new ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter[1])[0] = configuredTaskAwaiter2;
this.<>t__awaiter = array;
this.<>t__builder.AwaitUnsafeOnCompleted<ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter, Stream.<CopyToAsyncInternal>d__2>(ref array[0], ref this);
return;
}
IL_176:
int arg_185_0 = configuredTaskAwaiter2.GetResult();
configuredTaskAwaiter2 = default(ConfiguredTaskAwaitable<int>.ConfiguredTaskAwaiter);
int num = arg_185_0;
if ((this.<bytesRead>5__4 = num) != 0)
{
configuredTaskAwaiter = this.destination.WriteAsync(this.<buffer>5__3, 0, this.<bytesRead>5__4, this.cancellationToken).ConfigureAwait(false).GetAwaiter();
if (!configuredTaskAwaiter.IsCompleted)
{
this.<>1__state = 0;
ConfiguredTaskAwaitable.ConfiguredTaskAwaiter[] array2;
(array2 = new ConfiguredTaskAwaitable.ConfiguredTaskAwaiter[1])[0] = configuredTaskAwaiter;
this.<>t__awaiter = array2;
this.<>t__builder.AwaitUnsafeOnCompleted<ConfiguredTaskAwaitable.ConfiguredTaskAwaiter, Stream.<CopyToAsyncInternal>d__2>(ref array2[0], ref this);
return;
}
goto IL_CA;
}
}
catch (Exception exception)
{
this.<>1__state = -2;
this.<>t__builder.SetException(exception);
return;
}
this.<>1__state = -2;
this.<>t__builder.SetResult();
}
[DebuggerHidden]
void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine param0)
{
this.<>t__builder.SetStateMachine(param0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment