本文整理汇总了C#中System.Threading.Tasks.Tests.CancelWait.TaskInfo类的典型用法代码示例。如果您正苦于以下问题:C# TaskInfo类的具体用法?C# TaskInfo怎么用?C# TaskInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskInfo类属于System.Threading.Tasks.Tests.CancelWait命名空间,在下文中一共展示了TaskInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TaskCancelWait5
public static void TaskCancelWait5()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Light, "RespectParentCancellation");
TestParameters parameters = new TestParameters(node, API.Cancel, WaitBy.None, -1);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例2: TaskCancelWait1
public static void TaskCancelWait1()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Heavy, string.Empty, true);
TaskInfo node_1 = new TaskInfo(node, "node_1", WorkloadType.Light, string.Empty);
node.AddChildren(new[] { node_1, });
TestParameters parameters = new TestParameters(node, API.Cancel, WaitBy.None, -1);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例3: TaskCancelWait4
public static void TaskCancelWait4()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Light, "AttachedToParent");
TaskInfo node_1 = new TaskInfo(node, "node_1", WorkloadType.VeryHeavy, "RespectParentCancellation");
node.AddChildren(new[] { node_1, });
TestParameters parameters = new TestParameters(node, API.Cancel, WaitBy.None, -1);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例4: TaskCancelWait52
public static void TaskCancelWait52()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.VeryLight, "None");
TaskInfo node_1 = new TaskInfo(node, "node_1", WorkloadType.Medium, "LongRunning, RespectParentCancellation");
TaskInfo node_2 = new TaskInfo(node, "node_2", WorkloadType.VeryLight, "LongRunning, AttachedToParent");
TaskInfo node_3 = new TaskInfo(node, "node_3", WorkloadType.Medium, "RespectParentCancellation");
TaskInfo node_4 = new TaskInfo(node, "node_4", WorkloadType.VeryHeavy, "LongRunning");
TaskInfo node_5 = new TaskInfo(node, "node_5", WorkloadType.VeryHeavy, "LongRunning, RespectParentCancellation");
TaskInfo node_6 = new TaskInfo(node, "node_6", WorkloadType.VeryLight, "AttachedToParent");
TaskInfo node_7 = new TaskInfo(node, "node_7", WorkloadType.VeryLight, "LongRunning");
node.AddChildren(new[] { node_1, node_2, node_3, node_4, node_5, node_6, node_7, });
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.Millisecond, 0);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例5: TaskCancelWait49
public static void TaskCancelWait49()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.VeryLight, "LongRunning, AttachedToParent");
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.Millisecond, 0);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例6: TaskCancelWait120
public static void TaskCancelWait120()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.VeryLight, "LongRunning, RespectParentCancellation");
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.Millisecond, 27);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例7: TaskCancelWait126
public static void TaskCancelWait126()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Heavy, "AttachedToParent");
TaskInfo node_1 = new TaskInfo(node, "node_1", WorkloadType.VeryLight, "LongRunning, AttachedToParent");
TaskInfo node_2 = new TaskInfo(node, "node_2", WorkloadType.VeryLight, "None");
node.AddChildren(new[] { node_1, node_2, });
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.Millisecond, 27);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例8: VerifyResult
private void VerifyResult(TaskInfo current)
{
TaskInfo ti = current;
WorkloadType workType = ti.WorkType;
if (workType == WorkloadType.Exceptional && _api != API.Cancel)
{
bool expCaught = FindException((ex) =>
{
TPLTestException expectedExp = ex as TPLTestException;
return expectedExp != null && expectedExp.FromTaskId == ti.Task.Id;
});
if (!expCaught)
Assert.True(false, string.Format("expected TPLTestException in Task.Name = Task{0} NOT caught", current.Name));
}
else
{
if (ti.Task.Exception != null && _api == API.Wait)
Assert.True(false, string.Format("UNEXPECTED exception in Task.Name = Task{0} caught. Exception: {1}", current.Name, ti.Task.Exception));
if (ti.Task.IsCanceled && ti.Result != -42)
{
//this means that the task was not scheduled - it was cancelled or it is still in the queue
//-42 = UNINITIALED_RESULT
Assert.True(false, string.Format("Result must remain uninitialized for unstarted task"));
}
else if (ti.Task.IsCompleted)
{
//Function point comparison cant be done by rounding off to nearest decimal points since
//1.64 could be represented as 1.63999999 or as 1.6499999999. To perform floating point comparisons,
//a range has to be defined and check to ensure that the result obtained is within the specified range
double minLimit = 1.63;
double maxLimit = 1.65;
if (ti.Result < minLimit || ti.Result > maxLimit)
Assert.True(ti.Task.IsCanceled || ti.Task.IsFaulted,
string.Format(
"Expected Result to lie between {0} and {1} for completed task. Actual Result {2}. Using n={3} IsCanceled={4}",
minLimit,
maxLimit,
ti.Result,
workType,
ti.Task.IsCanceled));
}
}
}
示例9: VerifyWait
/// <summary>
/// Verify the Wait code path
/// </summary>
private void VerifyWait(TaskInfo current)
{
TaskInfo ti = current;
TaskInfo parent = current.Parent;
if (_taskCompleted)
{
if (parent == null)
{
Assert.True(ti.Task.IsCompleted, "Root task must complete");
}
else if (parent != null && parent.Task.IsCompleted)
{
if ((ti.Option & TaskCreationOptions.AttachedToParent) != 0
&& !ti.Task.IsCompleted)
{
Assert.True(false, string.Format("Inner attached task must complete"));
}
}
}
}
示例10: CaluateLeafNodes
/// <summary>
/// Walk the tree and calculates the tree nodes count
/// </summary>
/// <param name="tree"></param>
private int CaluateLeafNodes(TaskInfo tree)
{
if (tree.IsLeaf)
return 1;
int sum = 0;
foreach (TaskInfo child in tree.Children)
sum += CaluateLeafNodes(child);
return sum;
}
示例11: TaskCancelWait31
public static void TaskCancelWait31()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Heavy, "RespectParentCancellation");
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.Millisecond, -1);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例12: TaskCancelWait24
public static void TaskCancelWait24()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Medium, "LongRunning");
TaskInfo node_1 = new TaskInfo(node, "node_1", WorkloadType.Medium, "LongRunning, AttachedToParent");
TaskInfo node_2 = new TaskInfo(node, "node_2", WorkloadType.Light, "None");
node.AddChildren(new[] { node_1, node_2, });
TestParameters parameters = new TestParameters(node, API.Cancel, WaitBy.None, -1);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例13: TaskCancelWait19
public static void TaskCancelWait19()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Medium, "LongRunning, AttachedToParent");
TestParameters parameters = new TestParameters(node, API.Cancel, WaitBy.None, -1);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例14: TaskCancelWait141
public static void TaskCancelWait141()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Heavy, "LongRunning, RespectParentCancellation");
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.TimeSpan, 27);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}
示例15: TaskCancelWait137
public static void TaskCancelWait137()
{
TaskInfo node = new TaskInfo(null, "node", WorkloadType.Heavy, "RespectParentCancellation");
TaskInfo node_1 = new TaskInfo(node, "node_1", WorkloadType.Heavy, "RespectParentCancellation");
TaskInfo node_2 = new TaskInfo(node, "node_2", WorkloadType.Light, "RespectParentCancellation");
node.AddChildren(new[] { node_1, node_2, });
TestParameters parameters = new TestParameters(node, API.Wait, WaitBy.TimeSpan, 27);
TaskCancelWaitTest test = new TaskCancelWaitTest(parameters);
test.RealRun();
}