예제 #1
0
        public Task Iterate_NonGeneric_IteratorRunsInSynchronizationContext()
        {
            ThreadPoolSyncContext sc = new ThreadPoolSyncContext();

            SynchronizationContext.SetSynchronizationContext(sc);

            return(TaskHelpers.Iterate(SyncContextVerifyingEnumerable(sc)).Then(() =>
            {
                Assert.Same(sc, SynchronizationContext.Current);
            }));
        }
        public Task Iterate_Generic_IteratorRunsInSynchronizationContext()
        {
            ThreadPoolSyncContext sc = new ThreadPoolSyncContext();

            SynchronizationContext.SetSynchronizationContext(sc);

            return(TaskHelpers.Iterate(SyncContextVerifyingEnumerable_Generic(sc)).Then(result =>
            {
                Assert.Same(sc, SynchronizationContext.Current);
                Assert.Equal(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, result);
            }));
        }
예제 #3
0
 public ThreadPoolApartment()
 {
     _syncContext       = new ThreadPoolSyncContext(this);
     this.TaskScheduler = _syncContext.TaskScheduler;
 }