當前位置: 首頁>>代碼示例>>C#>>正文


C# CancelWait.TaskInfo類代碼示例

本文整理匯總了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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:12,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:12,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:24,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:14,代碼來源:TaskCancelWaitTests.cs

示例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));
                }
            }
        }
開發者ID:ChuangYang,項目名稱:corefx,代碼行數:48,代碼來源:TaskCancelWaitTest.cs

示例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"));
             }
         }
     }
 }
開發者ID:ChuangYang,項目名稱:corefx,代碼行數:23,代碼來源:TaskCancelWaitTest.cs

示例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;
        }
開發者ID:ChuangYang,項目名稱:corefx,代碼行數:15,代碼來源:TaskCancelWaitTest.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:14,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:9,代碼來源:TaskCancelWaitTests.cs

示例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();
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:14,代碼來源:TaskCancelWaitTests.cs


注:本文中的System.Threading.Tasks.Tests.CancelWait.TaskInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。