Пример #1
0
        public static Task Task(this IAsyncStateMachine sm)
        {
            // sm.Task
            var task = Expression.Lambda <Func <object> >(
                Expression.Property(
                    Expression.Field(Expression.Constant(sm), sm.BuilderField()),
                    sm.BuilderField().FieldType.GetProperty("Task"))).Compile().Invoke();

            return(task as Task);
        }