Exemplo n.º 1
0
        public void TestUnknown()
        {
            currentProgress = -1f;
            using (Progress.BeginUnknownTask(100, .75f).SetCallback(AssertProgressIsGrowing))
            {
                var count = 200; // Do way more than expected to make sure progress doesn't go over 100%.
                Console.WriteLine("Performing {0} iterations", count);
                for (int i = 0; i < count; i++)
                {
                    Console.Write("#{0:00}: ", i);
                    Progress.NextStep();

                    if (i == 100)
                    {
                        AssertCurrentProgress(75f);
                    }
                }
                Console.WriteLine("Done ({0} total)", count);
                Progress.EndTask();
            }
        }
Exemplo n.º 2
0
        public void TestUnknownTimer()
        {
            currentProgress = -1f;
            using (Progress.BeginWeightedTask(10f, 80f, 10f).SetCallback(AssertProgressIsGrowing))
            {
                Progress.SetTaskKey("Stall 1 second").NextStep();
                Progress.BeginFixedTask(10);
                for (int i = 0; i < 10; i++)
                {
                    Progress.NextStep();
                    System.Threading.Thread.Sleep(100);
                }
                Progress.EndTask();


                // Start a task that takes unknown time:
                Progress.SetTaskKey("Unknown for 8+ seconds").NextStep();
                using (Progress.BeginUnknownTask(8, .90f))
                {
                    System.Threading.Thread.Sleep(8000);
                    System.Threading.Thread.Sleep(3000); // Take some extra time!
                    Progress.EndTask();
                }


                Progress.SetTaskKey("Stall another second").NextStep();
                using (Progress.BeginFixedTask(10))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Progress.NextStep();
                        System.Threading.Thread.Sleep(100);
                    }
                    Progress.EndTask();
                }
                Progress.EndTask();
            }
        }