Skip to content

Commit

Permalink
Avoid TaskScheduler.Default in PLINQ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jan 18, 2015
1 parent 9d3ea49 commit b46a2c5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/System.Linq.Parallel/tests/WithCancellationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public static void ChannelCancellation_ProducerBlocked()
.Select(x => x);
var enumerator1 = query1.GetEnumerator();
enumerator1.MoveNext();
Task.Delay(1000);
Task.Delay(1000).Wait();
//Thread.Sleep(1000); // give the pipelining time to fill up some buffers.
enumerator1.MoveNext();
enumerator1.Dispose(); //can potentially hang
Expand Down Expand Up @@ -410,7 +410,7 @@ public static void CancellationSequentialWhere()

var q = src.AsParallel().WithCancellation(tokenSrc.Token).Where(x => false).TakeWhile(x => true);

Task task = Task.Factory.StartNew(
Task task = Task.Run(
() =>
{
try
Expand All @@ -432,7 +432,7 @@ public static void CancellationSequentialWhere()
// We wait for 100 ms. If we canceled the token source immediately, the cancellation
// would occur at the query opening time. The goal of this test is to test cancellation
// at query execution time.
Task.Delay(100);
Task.Delay(100).Wait();
//Thread.Sleep(100);

tokenSrc.Cancel();
Expand All @@ -445,7 +445,7 @@ public static void CancellationSequentialElementAt()
IEnumerable<int> src = Enumerable.Repeat(0, int.MaxValue);
CancellationTokenSource tokenSrc = new CancellationTokenSource();

Task task = Task.Factory.StartNew(
Task task = Task.Run(
() =>
{
try
Expand All @@ -468,7 +468,7 @@ public static void CancellationSequentialElementAt()
// We wait for 100 ms. If we canceled the token source immediately, the cancellation
// would occur at the query opening time. The goal of this test is to test cancellation
// at query execution time.
Task.WaitAll(Task.Delay(100));
Task.Delay(100).Wait();
//Thread.Sleep(100);

tokenSrc.Cancel();
Expand All @@ -481,7 +481,7 @@ public static void CancellationSequentialDistinct()
IEnumerable<int> src = Enumerable.Repeat(0, int.MaxValue);
CancellationTokenSource tokenSrc = new CancellationTokenSource();

Task task = Task.Factory.StartNew(
Task task = Task.Run(
() =>
{
try
Expand All @@ -505,7 +505,7 @@ public static void CancellationSequentialDistinct()
// We wait for 100 ms. If we canceled the token source immediately, the cancellation
// would occur at the query opening time. The goal of this test is to test cancellation
// at query execution time.
Task.Delay(100);
Task.Delay(100).Wait();
//Thread.Sleep(100);

tokenSrc.Cancel();
Expand Down Expand Up @@ -545,7 +545,7 @@ public static void SetOperationsThrowAggregateOnCancelOrDispose_1()

var walker = plinq.GetEnumerator();

t = Task.Factory.StartNew(() =>
t = Task.Run(() =>
{
mre.WaitOne();
cs.Cancel();
Expand Down

0 comments on commit b46a2c5

Please sign in to comment.