public void GetHangReportProducesDgmlWithMethodNameRequestingMainThread()
    {
        var mainThreadRequested = new ManualResetEventSlim();

        Task.Run(delegate
        {
            JoinableTaskFactory.MainThreadAwaiter awaiter = this.Factory.SwitchToMainThreadAsync().GetAwaiter();
            awaiter.OnCompleted(delegate { /* this anonymous delegate is expected to include the name of its containing method */ });
            mainThreadRequested.Set();
        });
        mainThreadRequested.Wait();
        IHangReportContributor contributor = this.Context;
        HangReportContribution?report      = contributor.GetHangReport();

        this.Logger.WriteLine(report.Content);
        var dgml = XDocument.Parse(report.Content);
        IEnumerable <string>?collectionLabels = from node in dgml.Root.Element(XName.Get("Nodes", DgmlNamespace)).Elements()
                                                where node.Attribute(XName.Get("Category"))?.Value == "Task"
                                                select node.Attribute(XName.Get("Label"))?.Value;

        Assert.Contains(collectionLabels, label => label.Contains(nameof(this.GetHangReportProducesDgmlWithMethodNameRequestingMainThread)));
    }
 public void OnCompleted(Action continuation)
 => _mainThreadAwaiter.OnCompleted(continuation);
Пример #3
0
 public void OnCompleted(Action continuation) => _awaiter.OnCompleted(continuation);