예제 #1
0
        public void TestAsyncLazy()
        {
            int tmpInt = 99;

            AsyncLazy <int> cls = new AsyncLazy <int>(() =>
            {
                return(Task <int> .Run(() => { tmpInt = 42; return tmpInt; }));
            });

            Assert.Equal <int>(99, tmpInt);
            int result42 = cls.GetAsync().GetAwaiter().GetResult();

            Assert.Equal <int>(42, tmpInt);
            Assert.Equal <int>(42, result42);
        }