Skip to content

Commit

Permalink
Revert fcbb571 and implement it differently.
Browse files Browse the repository at this point in the history
The commit had the good idea but since some values of the enumeration overlap it broke the correct behavior. Instead we now turn off the extra options and use the previous way to check.
  • Loading branch information
garuma committed Mar 21, 2011
1 parent 1e38c9d commit 6623fc5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 15 additions & 9 deletions mcs/class/corlib/System.Threading.Tasks/Task.cs
Expand Up @@ -283,26 +283,32 @@ bool ContinuationStatusCheck (TaskContinuationOptions kind)
int kindCode = (int)kind;

if (kindCode >= ((int)TaskContinuationOptions.NotOnRanToCompletion)) {
// Remove other options
kind &= ~(TaskContinuationOptions.PreferFairness
| TaskContinuationOptions.LongRunning
| TaskContinuationOptions.AttachedToParent
| TaskContinuationOptions.ExecuteSynchronously);

if (status == TaskStatus.Canceled) {
if ((kind & TaskContinuationOptions.NotOnCanceled) > 0)
if (kind == TaskContinuationOptions.NotOnCanceled)
return false;
if ((kind & TaskContinuationOptions.OnlyOnFaulted) > 0)
if (kind == TaskContinuationOptions.OnlyOnFaulted)
return false;
if ((kind & TaskContinuationOptions.OnlyOnRanToCompletion) > 0)
if (kind == TaskContinuationOptions.OnlyOnRanToCompletion)
return false;
} else if (status == TaskStatus.Faulted) {
if ((kind & TaskContinuationOptions.NotOnFaulted) > 0)
if (kind == TaskContinuationOptions.NotOnFaulted)
return false;
if ((kind & TaskContinuationOptions.OnlyOnCanceled) > 0)
if (kind == TaskContinuationOptions.OnlyOnCanceled)
return false;
if ((kind & TaskContinuationOptions.OnlyOnRanToCompletion) > 0)
if (kind == TaskContinuationOptions.OnlyOnRanToCompletion)
return false;
} else if (status == TaskStatus.RanToCompletion) {
if ((kind & TaskContinuationOptions.NotOnRanToCompletion) > 0)
if (kind == TaskContinuationOptions.NotOnRanToCompletion)
return false;
if ((kind & TaskContinuationOptions.OnlyOnFaulted) > 0)
if (kind == TaskContinuationOptions.OnlyOnFaulted)
return false;
if ((kind & TaskContinuationOptions.OnlyOnCanceled) > 0)
if (kind == TaskContinuationOptions.OnlyOnCanceled)
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs
Expand Up @@ -162,7 +162,8 @@ public void ContinueWithOnAbortedTestCase()
Task t = new Task(delegate { taskResult = true; }, src.Token);
src.Cancel ();

Task cont = t.ContinueWith (delegate { result = true; }, TaskContinuationOptions.OnlyOnCanceled);
Task cont = t.ContinueWith (delegate { result = true; },
TaskContinuationOptions.OnlyOnCanceled | TaskContinuationOptions.ExecuteSynchronously);

t.Start();
cont.Wait();
Expand Down

0 comments on commit 6623fc5

Please sign in to comment.