Beispiel #1
0
 private static void startButton_Click()
 {
     Program.startButton_Clickd__1 stateMachine = new Program.startButton_Clickd__1();
     stateMachine.t__builder = AsyncVoidMethodBuilder.Create();
     stateMachine.__state    = -1;
     stateMachine.t__builder.Start <Program.startButton_Clickd__1>(ref stateMachine);
 }
Beispiel #2
0
            void IAsyncStateMachine.MoveNext()
            {
                int num1 = this.__state;

                try
                {
                    TaskAwaiter <int> awaiter;
                    if (num1 != 0)
                    {
                        Console.WriteLine("ONE:   Entering startButton_Click.\r\n           Calling AccessTheWebAsync.\r\n");
                        this.getLengthTask5__1 = Program.AccessTheWebAsync();
                        Console.WriteLine("\r\nFOUR:  Back in startButton_Click.\r\n           Task getLengthTask is started.\r\n           About to await getLengthTask -- no caller to return to.\r\n");
                        awaiter = this.getLengthTask5__1.GetAwaiter();
                        if (!awaiter.IsCompleted)
                        {
                            this.__state = 0;
                            this.u__1    = awaiter;
                            Program.startButton_Clickd__1 stateMachine = this;
                            this.t__builder.AwaitUnsafeOnCompleted <TaskAwaiter <int>, Program.startButton_Clickd__1>(ref awaiter, ref stateMachine);
                            return;
                        }
                    }
                    else
                    {
                        awaiter      = this.u__1;
                        this.u__1    = new TaskAwaiter <int>();
                        this.__state = -1;
                    }
                    int result = awaiter.GetResult();
                    new TaskAwaiter <int>();
                    this.s__3 = result;
                    this.contentLength5__2 = this.s__3;
                    Console.WriteLine("\r\nSIX:   Back in startButton_Click.\r\n           Task getLengthTask is finished.\r\n           Result from AccessTheWebAsync is stored in contentLength.\r\n           About to display contentLength and exit.\r\n");
                    Console.WriteLine("\r\nLength of the downloaded string: {0}.\r\n", (object)this.contentLength5__2);
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    this.__state = -2;
                    this.t__builder.SetException(ex);
                    return;
                }
                this.__state = -2;
                this.t__builder.SetResult();
            }