Skip to content

Commit

Permalink
Fix for mono#162
Browse files Browse the repository at this point in the history
  • Loading branch information
garuma committed Aug 5, 2011
1 parent 89d18c3 commit 4553d5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mcs/class/corlib/System.Threading.Tasks/Task.cs
Expand Up @@ -121,7 +121,7 @@ public Task (Action<object> action, object state, CancellationToken cancellation
this.action = action;
this.state = state;
this.taskId = Interlocked.Increment (ref id);
this.status = TaskStatus.Created;
this.status = cancellationToken.IsCancellationRequested ? TaskStatus.Canceled : TaskStatus.Created;
this.token = cancellationToken;
this.parent = parent;

Expand Down
9 changes: 9 additions & 0 deletions mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs
Expand Up @@ -117,6 +117,15 @@ public void CancelTestCase()
Assert.AreEqual (1, aggr.InnerExceptions.Count, "#4");
Assert.IsInstanceOfType (typeof (OperationCanceledException), aggr.InnerExceptions[0], "#5");
}

[Test, ExpectedException (typeof (InvalidOperationException))]
public void CreationWhileInitiallyCanceled ()
{
var token = new CancellationToken (true);
var task = new Task (() => { }, token);
Assert.AreEqual (TaskStatus.Canceled, task.Status);
task.Start ();
}

[Test]
public void ContinueWithOnAnyTestCase()
Expand Down

0 comments on commit 4553d5d

Please sign in to comment.