protected override async Task ExecuteAsync(CancellationToken cancel) { _logger.LogInformation("Async worker started..."); //while (!cancel.IsCancellationRequested) { var callTree = CallTree.CreateTestCallGraph(); await callTree.Execute(_telemetry, _callTreeLogger); await Task.Delay(1000); } _logger.LogWarning("Async worker cancelled."); }
/// <summary> /// call A /// within A, call async a1 and a2 /// Then call B /// within B, call b1, then call b2 /// Call C /// within C, call async c1 and c2 /// also call c3 /// /// A(a1,a2)->B(b1->b2)->C((c1,c2)->c3) /// </summary> /// <returns></returns> public static CallTree CreateTestCallGraph() { var root = new CallTree("root"); var A = new CallTree("A", root); var a1 = new CallTree("a1", A) { IsAsynchronous = true }; var a2 = new CallTree("a2", A) { IsAsynchronous = true }; A.Children = new List <CallTree> { a1, a2 }; var B = new CallTree("B", root); var b1 = new CallTree("b1", B); var b2 = new CallTree("b2", B); B.Children = new List <CallTree> { b1, b2 }; var C = new CallTree("C", root); var c1 = new CallTree("c1", C) { IsAsynchronous = true }; var c2 = new CallTree("c2", C) { IsAsynchronous = true }; var c3 = new CallTree("c3", C); C.Children = new List <CallTree> { c1, c2, c3 }; root.Children = new List <CallTree> { A, B, C }; return(root); }