Ejemplo n.º 1
0
        static async Task DoItWithAsyncNoAwaitButConfigureAwaitFalse()
        {
            string currentMethodName = nameof(DoItWithAsyncNoAwaitButConfigureAwaitFalse);
            var    info = new InfoObject {
                MillisToSleep = 1333, TestCase = "AsyncNoAwaitButConfigureAwaitFalse"
            };
            var lenghtyStuff = new LengthyStuff();

            info.Log($"Start of <{currentMethodName}>");
            lenghtyStuff.TaskDelay(info, false).Wait();
            info.Log($"End of <{currentMethodName}>");
        }
Ejemplo n.º 2
0
        private async Task DoItWithAsyncNoAwaitButConfigureAwaitFalse()
        {
            string currentMethodName = nameof(DoItWithAsyncNoAwaitButConfigureAwaitFalse);
            var    info = new InfoObject {
                Logger = LogIt, MillisToSleep = GetSimulatedWorkInMillis(), TestCase = "NoAwaitButConfigureAwaitFalse"
            };
            var lenghtyStuff = new LengthyStuff();

            info.IncreaseIndentationLevel();
            info.Log($"Start of <{currentMethodName}> before hard waiting on Task.Delay");
            lenghtyStuff.TaskDelay(info, false).Wait();
            info.Log($"End of <{currentMethodName}> back from Task.Delay().Wait()");
            info.DecreaseIndentationLevel();
        }
Ejemplo n.º 3
0
        private async Task DoItInAsyncInNewThreadButConfigureAwaitFalse()
        {
            string currentMethodName = nameof(DoSyncCallViaTaskRunAndAsync);
            var    info = new InfoObject {
                Logger = LogIt, MillisToSleep = GetSimulatedWorkInMillis(), TestCase = "AsyncInNewThreadButConfigureAwaitFalse"
            };
            var lenghtyStuff = new LengthyStuff();

            info.IncreaseIndentationLevel();

            info.Log($"Begin of {currentMethodName} before Task.Delay");
            var task = Task.Run(() => lenghtyStuff.TaskDelay(info, false));

            info.Log($"In {currentMethodName} before awaiting Task-Delay");
            await task;

            info.Log($"End of {currentMethodName} after awaiting Task.Delay");
            info.DecreaseIndentationLevel();
        }