示例#1
0
        private Task DoItInSync()
        {
            var info = new InfoObject {
                Logger = LogIt, MillisToSleep = GetSimulatedWorkInMillis(), TestCase = "Sync"
            };
            var lenghtyStuff = new LengthyStuff();

            lenghtyStuff.DoItInSync(info);

            // in order to match delegate
            return(Task.Delay(0));
        }
示例#2
0
        static void DoItInSync()
        {
            string currentMethodName = nameof(DoItInSync);

            var info = new InfoObject {
                MillisToSleep = 1234, TestCase = "Sync"
            };
            var lenghtyStuff = new LengthyStuff();

            info.Log($"Start of <{currentMethodName}>");
            lenghtyStuff.DoItInSync(info);
            info.Log($"End of <{currentMethodName}>");
        }
示例#3
0
        private async Task DoSyncCallViaTaskRunAndAsync()
        {
            string currentMethodName = nameof(DoSyncCallViaTaskRunAndAsync);
            var    info = new InfoObject {
                Logger = LogIt, MillisToSleep = GetSimulatedWorkInMillis(), TestCase = "AsyncViaTaskRun"
            };
            var lenghtyStuff = new LengthyStuff();

            info.IncreaseIndentationLevel();

            info.Log($"Begin of {currentMethodName} before calling DoItInSync");
            var task = Task.Run(() => lenghtyStuff.DoItInSync(info));

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

            info.Log($"End of {currentMethodName} after awaiting DoItInSync");

            info.DecreaseIndentationLevel();
        }