Imported Upstream version 4.6.0.182

Former-commit-id: 439c182e520038bf50777ca2fe684f216ae28552
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-09-01 10:46:18 +00:00
parent c911219690
commit 804b15604f
118 changed files with 1007 additions and 891 deletions

View File

@ -1057,24 +1057,21 @@ namespace MonoTests.System.Threading.Tasks
var token = source.Token;
var evt = new ManualResetEventSlim ();
bool result = false;
bool thrown = false;
var task = Task.Factory.StartNew (() => evt.Wait (100));
var task = Task.Factory.StartNew (() => { Assert.IsTrue (evt.Wait (2000), "#1"); });
var cont = task.ContinueWith (t => result = true, token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
source.Cancel();
evt.Set ();
task.Wait (100);
Assert.IsTrue (task.Wait (2000), "#2");
try {
cont.Wait (100);
} catch (Exception ex) {
thrown = true;
Assert.IsFalse (cont.Wait (4000), "#3");
} catch (AggregateException ex) {
}
Assert.IsTrue (task.IsCompleted);
Assert.IsTrue (cont.IsCanceled);
Assert.IsFalse (result);
Assert.IsTrue (thrown);
Assert.IsTrue (task.IsCompleted, "#4");
Assert.IsTrue (cont.IsCanceled, "#5");
Assert.IsFalse (result, "#6");
}
[Test]