当前位置: 首页>>代码示例>>C#>>正文


C# ProgressIndicator.AddLine方法代码示例

本文整理汇总了C#中ProgressIndicator.AddLine方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressIndicator.AddLine方法的具体用法?C# ProgressIndicator.AddLine怎么用?C# ProgressIndicator.AddLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgressIndicator的用法示例。


在下文中一共展示了ProgressIndicator.AddLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestExtremelyLong

        protected void TestExtremelyLong()
        {
            const int SLEEP_TIME_MS = 10;
            int THREADS = System.Environment.ProcessorCount;
            const float TARGET_CPU_LOAD = 0.4f;

            Assert.IsTrue(THREADS <= System.Environment.ProcessorCount);

            ProgressIndicator pi = new ProgressIndicator("Crypto +4GB Test");

            pi.AddLine(String.Format("Configuration: {0} threads, CPU Load: {1}%", THREADS, TARGET_CPU_LOAD * 100));

            CancellationTokenSource src = new CancellationTokenSource();

            Task regulator = Task.Factory.StartNew(token =>
            {
                PerformanceCounter pc = new PerformanceCounter("Processor", "% Processor Time", "_Total");

                List<float> cpu_load = new List<float>();

                for (;;)
                {
                    const int PROBE_DELTA_MS = 200;
                    const int PROBE_COUNT = 30;
                    const int REGULATE_COUNT = 10;

                    for (int i = 0; i < REGULATE_COUNT; i++)
                    {
                        System.Threading.Thread.Sleep(PROBE_DELTA_MS);

                        cpu_load.Add(pc.NextValue() / 100);

                        if (src.IsCancellationRequested)
                            break;
                    }

                    while (cpu_load.Count > PROBE_COUNT)
                        cpu_load.RemoveFirst();

                    int old_transform_rounds = transform_rounds;

                    float avg_cpu_load = cpu_load.Average();

                    if (avg_cpu_load >= TARGET_CPU_LOAD)
                    {
                        transform_rounds = (int)Math.Round(transform_rounds * 0.9);

                        if (old_transform_rounds == transform_rounds)
                            transform_rounds--;
                    }
                    else
                    {
                        transform_rounds = (int)Math.Round(transform_rounds * 1.1);

                        if (old_transform_rounds == transform_rounds)
                            transform_rounds++;
                    }

                    if (transform_rounds == 0)
                        transform_rounds = 1;

                    if (src.IsCancellationRequested)
                        break;
                }
            }, src.Token);

            var partitioner = Partitioner.Create(Hashes.CryptoAll, EnumerablePartitionerOptions.None);

            Parallel.ForEach(partitioner, new ParallelOptions() { MaxDegreeOfParallelism = THREADS }, ht =>
            {
                IHash hash = (IHash)Activator.CreateInstance(ht);

                pi.AddLine(String.Format("{0} / {1} - {2} - {3}%", Hashes.CryptoAll.IndexOf(ht) + 1,
                    Hashes.CryptoAll.Count, hash.Name, 0));

                TestData test_data = TestData.Load(hash);

                int test_data_index = 0;

                for (int i = 0; i < test_data.Count; i++)
                {
                    if (test_data.GetRepeat(i) == 1)
                        continue;

                    test_data_index++;

                    ulong repeats = (ulong)test_data.GetRepeat(i);
                    byte[] data = test_data.GetData(i);
                    string expected_result = Converters.ConvertBytesToHexString(test_data.GetHash(i));

                    hash.Initialize();

                    int transform_counter = transform_rounds;
                    DateTime progress = DateTime.Now;

                    for (ulong j = 0; j < repeats; j++)
                    {
                        hash.TransformBytes(data);

                        transform_counter--;
//.........这里部分代码省略.........
开发者ID:relaxar,项目名称:HashLib,代码行数:101,代码来源:HashesTestBase.cs


注:本文中的ProgressIndicator.AddLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。