System.Threading.Tests.AsyncLocalTests.CaptureAndRestoreEmptyContext C# (CSharp) Метод

CaptureAndRestoreEmptyContext() приватный Метод

private CaptureAndRestoreEmptyContext ( ) : System.Threading.Tasks.Task
Результат System.Threading.Tasks.Task
        public static async Task CaptureAndRestoreEmptyContext()
        {
            AsyncLocal<int> local = new AsyncLocal<int>();

            ExecutionContext ec = ExecutionContext.Capture();

            local.Value = 12;

            ExecutionContext.Run(
                ec,
                _ =>
                {
                    Assert.Equal(local.Value, 0);
                    local.Value = 56;
                },
                null);

            Assert.Equal(local.Value, 12);
        }