Skip to content

Commit

Permalink
Release continuation ancestor before running. Fixes #15036
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Oct 9, 2013
1 parent f33bd8a commit e5bd8bc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mcs/class/corlib/System.Threading.Tasks/Task.cs
Expand Up @@ -49,8 +49,8 @@ public class Task : IDisposable, IAsyncResult

// parent is the outer task in which this task is created
readonly Task parent;
// contAncestor is the Task on which this continuation was setup
readonly Task contAncestor;
// A reference to a Task on which this continuation is attached to
Task contAncestor;

static int id = -1;
static readonly TaskFactory defaultFactory = new TaskFactory ();
Expand Down Expand Up @@ -500,7 +500,9 @@ internal void ChildCompleted (AggregateException childEx)
void InnerInvoke ()
{
if (IsContinuation) {
invoker.Invoke (contAncestor, state, this);
var ancestor = contAncestor;
contAncestor = null;
invoker.Invoke (ancestor, state, this);
} else {
invoker.Invoke (this, state, this);
}
Expand Down

0 comments on commit e5bd8bc

Please sign in to comment.