提交 72cdee95 编写于 作者: K Koundinya Veluri

Fix TaskStatusTests.TaskStatus3

Fixes dotnet/corefx#14839:
- This test is failing occasionally
- The parent task's status verification did not account for the child and parent tasks completing just before the verification


Commit migrated from https://github.com/dotnet/corefx/commit/e32c99048526e2134eb68f0caa144550cbfee4b2
上级 545084d4
......@@ -172,11 +172,21 @@ internal void RealRun()
{
//we may have reach this point too soon, let's keep spinning until the status changes.
while (_task.Status == TaskStatus.Running)
;
{
Task.Delay(1).Wait();
}
//
// If we're still waiting for children our Status should reflect so
// If we're still waiting for children our Status should reflect so. For this verification, read the
// parent task's status before the child task's status to make the child task's status more recent,
// since the child task may complete during the status reads.
//
if (_task.Status != TaskStatus.WaitingForChildrenToComplete)
TaskStatus taskStatus = _task.Status;
Interlocked.MemoryBarrier();
TaskStatus childTaskStatus = _childTask.Status;
if (taskStatus != TaskStatus.WaitingForChildrenToComplete &&
childTaskStatus != TaskStatus.RanToCompletion &&
childTaskStatus != TaskStatus.Faulted)
{
Assert.True(false, string.Format("Expecting currrent Task status to be WaitingForChildren but getting {0}", _task.Status.ToString()));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册