Esempio n. 1
0
        public async Task ForkedContext()
        {
            var value = new GenericParameterHelper();

            this.asyncLocal.Value = value;
            await Task.WhenAll(
                Task.Run(delegate
            {
                Assert.Same(value, this.asyncLocal.Value);
                this.asyncLocal.Value = null;
                Assert.Null(this.asyncLocal.Value);
            }),
                Task.Run(delegate
            {
                Assert.Same(value, this.asyncLocal.Value);
                this.asyncLocal.Value = null;
                Assert.Null(this.asyncLocal.Value);
            }));

            Assert.Same(value, this.asyncLocal.Value);
            this.asyncLocal.Value = null;
            Assert.Null(this.asyncLocal.Value);
        }