示例#1
0
        // that blocks ui-thread
        private async Task DoItWithAsyncNoAwaitButWaitWillBlockOnUiThread()
        {
            var info = new InfoObject {
                Logger = LogIt, MillisToSleep = 2000, TestCase = "AsyncNoAwaitWillBlockInUI-Thread"
            };
            var lenghtyStuff = new LengthyStuff();

            lenghtyStuff.DoItInAsync(info).Wait();
        }
示例#2
0
        private async Task DoItWithAsyncAndAwait()
        {
            var info = new InfoObject {
                Logger = LogIt, MillisToSleep = GetSimulatedWorkInMillis(), TestCase = "AsyncAndAwait"
            };
            var lenghtyStuff = new LengthyStuff();

            await lenghtyStuff.DoItInAsync(info);
        }
示例#3
0
        static async Task DoItWithAsyncNoAwaitButWaitDoesNotBlockInConsole()
        {
            string currentMethodName = nameof(DoItWithAsyncNoAwaitButWaitDoesNotBlockInConsole);
            var    info = new InfoObject {
                MillisToSleep = 1246, TestCase = "AsyncNoAwaitNonBlockingInConsole"
            };
            var lenghtyStuff = new LengthyStuff();

            info.Log($"Start of <{currentMethodName}>");
            lenghtyStuff.DoItInAsync(info).Wait();
            info.Log($"End of <{currentMethodName}>");
        }
示例#4
0
        static async Task DoItWithAsyncAndAwait()
        {
            string currentMethodName = nameof(DoItWithAsyncAndAwait);
            var    info = new InfoObject {
                MillisToSleep = 1357, TestCase = "AsyncAndAwait"
            };
            var lenghtyStuff = new LengthyStuff();

            info.Log($"Start of <{currentMethodName}>");
            await lenghtyStuff.DoItInAsync(info);

            info.Log($"End of <{currentMethodName}>");
        }