コード例 #1
0
        protected JoinableTaskTestBase(ITestOutputHelper logger)
            : base(logger)
        {
            this.dispatcherContext = SingleThreadedTestSynchronizationContext.New();
            SynchronizationContext.SetSynchronizationContext(this.dispatcherContext);
            this.context                 = this.CreateJoinableTaskContext();
            this.joinableCollection      = this.context.CreateCollection();
            this.asyncPump               = this.context.CreateFactory(this.joinableCollection);
            this.originalThreadManagedId = Environment.CurrentManagedThreadId;
            this.testFrame               = SingleThreadedTestSynchronizationContext.NewFrame();

            // Suppress the assert dialog that appears and causes test runs to hang.
            Trace.Listeners.OfType <DefaultTraceListener>().Single().AssertUiEnabled = false;
        }
コード例 #2
0
    protected JoinableTaskTestBase(ITestOutputHelper logger)
        : base(logger)
    {
        this.dispatcherContext = SingleThreadedTestSynchronizationContext.New();
        SynchronizationContext.SetSynchronizationContext(this.dispatcherContext);
#pragma warning disable CA2214 // Do not call overridable methods in constructors
        this.context = this.CreateJoinableTaskContext();
#pragma warning restore CA2214 // Do not call overridable methods in constructors
        this.joinableCollection      = this.context.CreateCollection();
        this.asyncPump               = this.context.CreateFactory(this.joinableCollection);
        this.originalThreadManagedId = Environment.CurrentManagedThreadId;
        this.testFrame               = SingleThreadedTestSynchronizationContext.NewFrame();

        // Suppress the assert dialog that appears and causes test runs to hang.
        if (Trace.Listeners.OfType <DefaultTraceListener>().FirstOrDefault() is { } listener)
        {
            listener.AssertUiEnabled = false;
        }
    }