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


C# ProgressBar.Tick方法代码示例

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


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

示例1: Main

		static void Main(string[] args)
		{
			var ticks = 10;
			using (var pbar = new ProgressBar(ticks, "A console progress bar that never ticks"))
			{
			}
			using (var pbar = new ProgressBar(ticks, "A console progress bar does not complete"))
			{
				pbar.Tick();
				pbar.Tick();
				pbar.Tick();
				pbar.Tick();
			}
			ticks = 100;
			using (var pbar = new ProgressBar(ticks, "my long running operation", ConsoleColor.Green))
			{
				for (var i = 0; i < ticks; i++)
				{
					pbar.Tick("step " + i);
					Thread.Sleep(50);
				}
			}
			ticks = 0;
			using (var pbar = new ProgressBar(ticks, "my operation with zero ticks", ConsoleColor.Cyan))
			{
				for (var i = 0; i < ticks; i++)
				{
					pbar.Tick("step " + i);
					Thread.Sleep(50);
				}
			}
			ticks = -100;
			using (var pbar = new ProgressBar(ticks, "my operation with negative ticks", ConsoleColor.Cyan))
			{
				for (var i = 0; i < ticks; i++)
				{
					pbar.Tick("step " + i);
					Thread.Sleep(50);
				}
			}
			ticks = 10;
			using (var pbar = new ProgressBar(ticks, "My operation that ticks to often", ConsoleColor.Cyan))
			{
				for (var i = 0; i < ticks * 10; i++)
				{
					pbar.Tick("too many steps " + i);
					Thread.Sleep(50);
				}
			}
			ticks = 200;
			using (var pbar = new ProgressBar(ticks / 10, "My operation that ticks to often using threads", ConsoleColor.Cyan))
			{
				var threads = Enumerable.Range(0, ticks).Select(i => new Thread(() => pbar.Tick("threaded tick " + i))).ToList();
				foreach (var thread in threads) thread.Start();
				foreach (var thread in threads) thread.Join();
			}
			Console.ReadLine();
		}
开发者ID:DaemonOverlord,项目名称:shellprogressbar,代码行数:58,代码来源:Program.cs

示例2: Start

 public Task Start(CancellationToken token)
 {
     var ticks = 5;
     using (var pbar = new ProgressBar(ticks, "A console progress bar does not complete"))
     {
         pbar.Tick();
         pbar.Tick();
         pbar.Tick();
         pbar.Tick();
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:12,代码来源:NeverCompletesExample.cs

示例3: Start

 public Task Start(CancellationToken token)
 {
     var ticks = 200;
     using (var pbar = new ProgressBar(ticks/10, "My operation that ticks to often using threads", ConsoleColor.Cyan))
     {
         var threads = Enumerable.Range(0, ticks).Select(i => new Thread(() => pbar.Tick("threaded tick " + i))).ToList();
         foreach (var thread in threads) thread.Start();
         foreach (var thread in threads) thread.Join();
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:11,代码来源:ThreadedTicksOverflowExample.cs

示例4: Start

 public Task Start(CancellationToken token)
 {
     var ticks = 10;
     using (var pbar = new ProgressBar(ticks, "My operation that ticks to often", ConsoleColor.Cyan))
     {
         for (var i = 0; i < ticks*10; i++)
         {
             pbar.Tick("too many steps " + i);
             Thread.Sleep(50);
         }
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:13,代码来源:TicksOverflowExample.cs

示例5: Start

 public Task Start(CancellationToken token)
 {
     var ticks = 0;
     using (var pbar = new ProgressBar(ticks, "my operation with zero ticks", ConsoleColor.Cyan))
     {
         for (var i = 0; i < ticks; i++)
         {
             pbar.Tick("step " + i);
             Thread.Sleep(50);
         }
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:13,代码来源:ZeroMaxTicksExample.cs

示例6: Start

 public Task Start(CancellationToken token)
 {
     var outerTicks = 10;
     using (var pbar = new ProgressBar(outerTicks, "outer progress", ConsoleColor.Cyan))
     {
         for (var i = 0; i < outerTicks; i++)
         {
             InnerProgressBars(pbar);
             pbar.Tick();
         }
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:13,代码来源:NestedProgressBarPerStepProgress.cs

示例7: Start

        public Task Start(CancellationToken token)
        {
            var random = new Random();

            var numberOfSteps = 7;

            var overProgressOptions = new ProgressBarOptions
            {
                BackgroundColor = ConsoleColor.DarkGray,
            };

            using (var pbar = new ProgressBar(numberOfSteps, "overal progress", overProgressOptions))
            {
                var stepBarOptions = new ProgressBarOptions
                {
                    ForeGroundColor = ConsoleColor.Cyan,
                    ForeGroundColorDone = ConsoleColor.DarkGreen,
                    ProgressCharacter = '─',
                    BackgroundColor = ConsoleColor.DarkGray,
                    CollapseWhenFinished = false,

                } ;
                Parallel.For(0, numberOfSteps, (i) =>
                {
                    var workBarOptions = new ProgressBarOptions
                    {
                        ForeGroundColor = ConsoleColor.Yellow,
                        ProgressCharacter = '─',
                        BackgroundColor = ConsoleColor.DarkGray,
                    };
                    var childSteps = random.Next(1, 5);
                    using (var childProgress = pbar.Spawn(childSteps, $"step {i} progress", stepBarOptions))
                        Parallel.For(0, childSteps, (ci) =>
                        {
                            var childTicks = random.Next(50, 250);
                            using (var innerChildProgress = childProgress.Spawn(childTicks, $"step {i}::{ci} progress", workBarOptions))
                            {
                                for (var r = 0; r < childTicks; r++)
                                {
                                    innerChildProgress.Tick();
                                    Program.BusyWait(50);
                                }
                            }
                            childProgress.Tick();
                        });

                    pbar.Tick();
                });
            }
            return Task.FromResult(1);
        }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:51,代码来源:DeeplyNestedProgressBarTreeExample.cs

示例8: Start

 public Task Start(CancellationToken token)
 {
     var ticks = 5;
     var updateOnTicksOnlyOptions = new ProgressBarOptions {DisplayTimeInRealTime = false};
     using (var pbar = new ProgressBar(ticks, "only update time on ticks", updateOnTicksOnlyOptions))
     {
         for (var i = 0; i < ticks; i++)
         {
             pbar.Tick("only update time on ticks, current: " + i);
             Thread.Sleep(1750);
         }
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:14,代码来源:DrawsOnlyOnTickExample.cs

示例9: Start

 public Task Start(CancellationToken token)
 {
     var ticks = 10;
     using (var pbar = new ProgressBar(ticks, "My operation that updates maxTicks", ConsoleColor.Cyan))
     {
         var sleep = 1000;
         for (var i = 0; i < ticks; i++)
         {
             pbar.Tick("Updating maximum ticks " + i);
             if (i == 5)
             {
                 ticks = 120;
                 pbar.UpdateMaxTicks(ticks);
                 sleep = 50;
             }
             Thread.Sleep(sleep);
         }
     }
     return Task.FromResult(1);
 }
开发者ID:codejnki,项目名称:shellprogressbar,代码行数:20,代码来源:UpdatesMaxTicksExample.cs


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