Ejemplo n.º 1
0
        public DispatcherThreadFixture()
        {
            // ThreadHelper in VS requires a persistent dispatcher thread.  Because
            // each unit test executes on a new thread, we create our own
            // persistent thread that acts like a UI thread. This will be invoked just
            // once for the module.
            _dispatcherThread = new DispatcherThread();

            _dispatcherThread.Invoke(() =>
            {
                // Internally this calls ThreadHelper.SetUIThread(), which
                // causes ThreadHelper to remember this thread for the
                // lifetime of the process as the dispatcher thread.
                var serviceProvider = ServiceProvider.GlobalProvider;
            });

            _joinableTaskContextNode = new JoinableTaskContextNode(
                new JoinableTaskContext(_dispatcherThread.Thread, _dispatcherThread.SyncContext));
        }
        public DispatcherThreadFixture()
        {
            // ThreadHelper in VS requires a persistent dispatcher thread.  Because
            // each unit test executes on a new thread, we create our own
            // persistent thread that acts like a UI thread. This will be invoked just
            // once for the module.
            _dispatcherThread = new DispatcherThread();

            _dispatcherThread.Invoke(() =>
            {
                // Internally this calls ThreadHelper.SetUIThread(), which
                // causes ThreadHelper to remember this thread for the
                // lifetime of the process as the dispatcher thread.
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
                var serviceProvider = ServiceProvider.GlobalProvider;
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
            });

            _joinableTaskContextNode = new JoinableTaskContextNode(
#pragma warning disable VSSDK005 // Avoid instantiating JoinableTaskContext
                new JoinableTaskContext(_dispatcherThread.Thread, _dispatcherThread.SyncContext));
#pragma warning restore VSSDK005 // Avoid instantiating JoinableTaskContext
        }