Esempio n. 1
0
 async ValueTask <int> Method_NestedInUsingScope()
 {
     using (new Process())
     {
         return(await ValueTasks.FromResult(3));
     }
 }
Esempio n. 2
0
        async ValueTask <int> Method3_AwaitNonLast()
        {
            await ValueTasks.Delay(10);

            var result = await ValueTasks.FromResult(3);

            return(result);
        }
Esempio n. 3
0
        async ValueTask <int> Method5()
        {
            await ValueTasks.Delay(10);

            return(await ValueTasks.FromResult(3));

            int LocalFunction() => 4;
        }
Esempio n. 4
0
        async ValueTask <int> Method_UsingDeclaration(int x)
        {
            using var p = new Process();

            if (x > 2)
            {
                return(await ValueTasks.FromResult(3));
            }
        }
Esempio n. 5
0
        async ValueTask <int> Method4()
        {
            if (Environment.UserInteractive)
            {
                return(await ValueTasks.FromResult(3));
            }

            await ValueTasks.Delay(10);

            return(await ValueTasks.FromResult(4));
        }
Esempio n. 6
0
 async ValueTask <int> Method_NestedInTryBlock()
 {
     try
     {
         return(await ValueTasks.FromResult(3));
     }
     catch
     {
         throw;
     }
 }
Esempio n. 7
0
 async Task <int> Method_NestedInTryBlock(int x)
 {
     try
     {
         if (x > 2)
         {
             return(await ValueTasks.FromResult(3));
         }
     }
     catch
     {
         throw;
     }
 }
Esempio n. 8
0
 async ValueTask <int> Method7() => await ValueTasks.FromResult(3);
Esempio n. 9
0
 async ValueTask Method6() => await ValueTasks.FromResult(3);
Esempio n. 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;
                }
            };
        }
    }
Esempio n. 11
0
        async ValueTask <int> Method_UsingDeclaration()
        {
            using var p = new Process();

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