Imported Upstream version 4.2.1.91

Former-commit-id: b6ad0994c58eaf044e2599fe2ff7996e073c87d2
This commit is contained in:
Xamarin Public Jenkins
2015-10-30 12:42:46 -04:00
committed by Jo Shields
parent bdd40f83c0
commit bac3554225
48 changed files with 211 additions and 83 deletions

View File

@ -33,7 +33,6 @@ using System;
using System.Threading;
using NUnit.Framework;
using System.Threading.Tasks;
using MonoTests.System.Threading.Tasks;
namespace MonoTests.System.Threading
{
@ -447,10 +446,11 @@ namespace MonoTests.System.Threading
Assert.IsTrue (canceled, "#3");
}
[Category ("NotWorking")] // why would linked token be imune to ObjectDisposedException on Cancel?
[Test]
public void ConcurrentCancelLinkedTokenSourceWhileDisposing ()
{
ParallelTestHelper.Repeat (delegate {
for (int i = 0, total = 500; i < total; ++i) {
var src = new CancellationTokenSource ();
var linked = CancellationTokenSource.CreateLinkedTokenSource (src.Token);
var cntd = new CountdownEvent (2);
@ -470,20 +470,19 @@ namespace MonoTests.System.Threading
t2.Start ();
t1.Join (500);
t2.Join (500);
}, 500);
}
}
#if NET_4_5
[Test]
public void DisposeRace ()
{
for (int i = 0; i < 1000; ++i) {
for (int i = 0, total = 1000; i < total; ++i) {
var c1 = new CancellationTokenSource ();
using (c1) {
var wh = c1.Token.WaitHandle;
c1.CancelAfter (1);
Thread.Sleep (1);
}
var wh = c1.Token.WaitHandle;
c1.CancelAfter (1);
Thread.Sleep (1);
c1.Dispose ();
}
}
#endif