Beispiel #1
0
        async ValueTask <int> Method5()
        {
            await ValueTasks.Delay(10);

            return(await ValueTasks.FromResult(3));

            int LocalFunction() => 4;
        }
Beispiel #2
0
        async ValueTask <int> Method3_AwaitNonLast()
        {
            await ValueTasks.Delay(10);

            var result = await ValueTasks.FromResult(3);

            return(result);
        }
Beispiel #3
0
        async ValueTask <int> Method_AwaitNonLast()
        {
            await ValueTasks.Delay(10);

            await ValueTasks.Delay(20);

            return(3);
        }
Beispiel #4
0
        async ValueTask Method2_AwaitNonLast()
        {
            using (new Process())
            {
                await ValueTasks.Delay(10);

                await ValueTasks.Delay(20);
            }
        }
Beispiel #5
0
        async ValueTask <int> Method4()
        {
            if (Environment.UserInteractive)
            {
                return(await ValueTasks.FromResult(3));
            }

            await ValueTasks.Delay(10);

            return(await ValueTasks.FromResult(4));
        }
Beispiel #6
0
        async ValueTask Method2()
        {
            if (Environment.UserInteractive)
            {
                await ValueTasks.Delay(10);
            }

            await ValueTasks.Delay(20);

            int LocalFunction()
            {
                return(4);
            }
        }
Beispiel #7
0
 async ValueTask Method_WithConfigureAwait_AsExpressionBodied() => await ValueTasks.Delay(10).ConfigureAwait(false);
Beispiel #8
0
 async ValueTask Method_WithConfigureAwait()
 {
     await ValueTasks.Delay(10).ConfigureAwait(false);
 }
Beispiel #9
0
 async ValueTask Method3() => await ValueTasks.Delay(10);
Beispiel #10
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;
                }
            };
        }
    }
Beispiel #11
0
        async ValueTask Method()
        {
            await ValueTasks.Delay(10);

            await ValueTasks.Delay(20);
        }