Пример #1
0
 async ValueTask <int> Method_NestedInUsingScope()
 {
     using (new Process())
     {
         return(await ValueTasks.FromResult(3));
     }
 }
Пример #2
0
        async ValueTask <int> Method5()
        {
            await ValueTasks.Delay(10);

            return(await ValueTasks.FromResult(3));

            int LocalFunction() => 4;
        }
Пример #3
0
        async ValueTask <int> Method_AwaitNonLast()
        {
            await ValueTasks.Delay(10);

            await ValueTasks.Delay(20);

            return(3);
        }
Пример #4
0
        async ValueTask <int> Method3_AwaitNonLast()
        {
            await ValueTasks.Delay(10);

            var result = await ValueTasks.FromResult(3);

            return(result);
        }
Пример #5
0
        async ValueTask Method2_AwaitNonLast()
        {
            using (new Process())
            {
                await ValueTasks.Delay(10);

                await ValueTasks.Delay(20);
            }
        }
Пример #6
0
        async ValueTask <int> Method_UsingDeclaration(int x)
        {
            using var p = new Process();

            if (x > 2)
            {
                return(await ValueTasks.FromResult(3));
            }
        }
Пример #7
0
        async ValueTask <int> Method4()
        {
            if (Environment.UserInteractive)
            {
                return(await ValueTasks.FromResult(3));
            }

            await ValueTasks.Delay(10);

            return(await ValueTasks.FromResult(4));
        }
Пример #8
0
 async ValueTask <int> Method_NestedInTryBlock()
 {
     try
     {
         return(await ValueTasks.FromResult(3));
     }
     catch
     {
         throw;
     }
 }
Пример #9
0
 async Task <int> Method_NestedInTryBlock(int x)
 {
     try
     {
         if (x > 2)
         {
             return(await ValueTasks.FromResult(3));
         }
     }
     catch
     {
         throw;
     }
 }
Пример #10
0
        async ValueTask Method2()
        {
            if (Environment.UserInteractive)
            {
                await ValueTasks.Delay(10);
            }

            await ValueTasks.Delay(20);

            int LocalFunction()
            {
                return(4);
            }
        }
Пример #11
0
 async ValueTask Method_WithConfigureAwait_AsExpressionBodied() => await ValueTasks.Delay(10).ConfigureAwait(false);
Пример #12
0
 async ValueTask Method_WithConfigureAwait()
 {
     await ValueTasks.Delay(10).ConfigureAwait(false);
 }
Пример #13
0
 async ValueTask <int> Method7() => await ValueTasks.FromResult(3);
Пример #14
0
 async ValueTask Method6() => await ValueTasks.FromResult(3);
Пример #15
0
        async ValueTask <int> Method_UsingDeclaration()
        {
            using var p = new Process();

            return(await ValueTasks.FromResult(35));
        }
Пример #16
0
 async ValueTask Method3() => await ValueTasks.Delay(10);
Пример #17
0
        void Method()
        {
            Func <ValueTask> Method = async() =>
            {
                await ValueTasks.Delay(10);

                await ValueTasks.Delay(20);
            };

            Func <ValueTask> Method2 = async() =>
            {
                if (Environment.UserInteractive)
                {
                    await ValueTasks.Delay(10);
                }

                await ValueTasks.Delay(20);

                int LocalFunction()
                {
                    return(4);
                }
            };

            Func <ValueTask> Method3 = async() => await ValueTasks.Delay(10);

            Func <ValueTask <int> > Method4 = async() =>
            {
                if (Environment.UserInteractive)
                {
                    return(await ValueTasks.FromResult(3));
                }

                await ValueTasks.Delay(10);

                return(await ValueTasks.FromResult(4));
            };

            Func <ValueTask <int> > Method5 = async() =>
            {
                await ValueTasks.Delay(10);

                return(await ValueTasks.FromResult(3));

                int LocalFunction() => 4;
            };

            Func <ValueTask> Method6 = async() => await ValueTasks.FromResult(3);

            Func <ValueTask <int> > Method7 = async() => await ValueTasks.FromResult(3);

            Func <ValueTask <int> > Method_AwaitNonLast = async() =>
            {
                await ValueTasks.Delay(10);

                await ValueTasks.Delay(20);

                return(3);
            };

            Func <ValueTask> Method2_AwaitNonLast = async() =>
            {
                using (new Process())
                {
                    await ValueTasks.Delay(10);

                    await ValueTasks.Delay(20);
                }
            };

            Func <ValueTask <int> > Method3_AwaitNonLast = async() =>
            {
                await ValueTasks.Delay(10);

                var result = await ValueTasks.FromResult(3);

                return(result);
            };

            Func <ValueTask> Method_WithConfigureAwait = async() => { await ValueTasks.Delay(10).ConfigureAwait(false); };

            Func <ValueTask> Method_WithConfigureAwait_AsExpressionBodied = async() => await ValueTasks.Delay(10).ConfigureAwait(false);

            Func <ValueTask <int> > Method_NestedInUsingScope = async() =>
            {
                using (new Process())
                {
                    return(await ValueTasks.FromResult(3));
                }
            };

            Func <ValueTask <int> > Method_NestedInUsingScope = async(int x) =>
            {
                using (new Process())
                {
                    if (x > 2)
                    {
                        return(await ValueTasks.FromResult(3));
                    }
                }
            };

            Func <ValueTask <int> > Method_UsingDeclaration = async() =>
            {
                using var p = new Process();

                return(await ValueTasks.FromResult(3));
            };

            Func <ValueTask <int> > Method_UsingDeclaration = async(int x) =>
            {
                using var p = new Process();

                if (x > 2)
                {
                    return(await ValueTasks.FromResult(3));
                }
            };

            Func <ValueTask <int> > Method_NestedInTryBlock = async() =>
            {
                try
                {
                    return(await ValueTasks.FromResult(3));
                }
                catch
                {
                    throw;
                }
            };

            Func <ValueTask <int> > Method_NestedInTryBlock = async(int x) =>
            {
                try
                {
                    if (x > 2)
                    {
                        return(await ValueTasks.FromResult(3));
                    }
                }
                catch
                {
                    throw;
                }
            };
        }
    }
Пример #18
0
        async ValueTask Method()
        {
            await ValueTasks.Delay(10);

            await ValueTasks.Delay(20);
        }