// 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(); }
private async Task DoItWithAsyncAndAwait() { var info = new InfoObject { Logger = LogIt, MillisToSleep = GetSimulatedWorkInMillis(), TestCase = "AsyncAndAwait" }; var lenghtyStuff = new LengthyStuff(); await lenghtyStuff.DoItInAsync(info); }
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}>"); }
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}>"); }