[c#]控制台进度条的示例
感觉很好玩,翻译成C#版。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleProcessBar
{
class Program
{
static void Main(string[] args)
{
Boolean isBreak = false;
ConsoleColor colorBack = Console.BackgroundColor;
ConsoleColor colorFore = Console.ForegroundColor;
//(0,0)(Left,Top) 第一行
Console.WriteLine("***********TE Mason*************");
Console.BackgroundColor = ConsoleColor.DarkCyan;
for (int i = 0; i < Console.WindowWidth - 3; i++)
{
//(0,1) 第二行
Console.Write(" ");
}
//(0,1) 第二行
Console.WriteLine(" ");
Console.BackgroundColor = colorBack;
//'(0,2) 第三行
Console.WriteLine("0%");
// '(0,3) 第四行
Console.WriteLine("<按【Enter】键停止>");
for (int i = 0; i <= 100; i++)
{
if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Enter)
{
isBreak = true;
break;
}
Console.BackgroundColor = ConsoleColor.Yellow;
// '/返回完整的商,包括余数,SetCursorPosition会自动四舍五入
Console.SetCursorPosition(i * (Console.WindowWidth - 2) / 100, 1);
// 'MsgBox(i * (Console.WindowWidth - 2) / 100);
// 'MsgBox(Console.CursorLeft);
//'MsgBox(Console.CursorSize);
Console.Write(" ");
Console.BackgroundColor = colorBack;
Console.ForegroundColor = ConsoleColor.Green;
Console.SetCursorPosition(0, 2);
Console.Write("{0}%", i);
Console.ForegroundColor = colorFore;
Thread.Sleep(500);
}
Console.SetCursorPosition(0, 3);
Console.Write(isBreak ? "停止!!!" : "完成");
Console.WriteLine(" ");
Console.ReadKey();
Console.ReadKey(true);
}
}
}

[c#]控制台进度条的示例的更多相关文章
- [vb.net]控制台进度条的示例
Private Sub ConsoleProcessBar() Dim isBreak As Boolean = False Dim colorBack As ConsoleColor = Conso ...
- 用C#实现控制台进度条
在写一些简单的控制台测试程序时,经常希望能够在程序运行的过程中实现进度条的功能以便查看程序运行的速度或者进度.本文以C#为例,实现简单的控制台进度条,以供大家参考(本文底部附下载地址). 1.实现效果 ...
- Python 控制台进度条的实现
进行爬虫等耗时的任务时,有时会想在控制台输出进度条,以显示当前任务进度.这里总结了两种方法. 方法1:使用tqdm模块 示例代码: from time import sleep from tqdm i ...
- Python中如何写控制台进度条的整理
本文实例讲述了Python显示进度条的方法,是Python程序设计中非常实用的技巧.分享给大家供大家参考.具体方法如下: 首先,进度条和一般的print区别在哪里呢? 答案就是print会输出一个\n ...
- ruby 编写控制台进度条
ruby 中,$stdout.flush 让控制台当前行内容可以重写,以此我们可以做出进度条的效果. def set_progress(index, char = '*') print (char * ...
- php+javascript实现的动态显示服务器运行程序进度条功能示例
本文实例讲述了php+javascript实现的动态显示服务器运行程序进度条功能.分享给大家供大家参考,具体如下: 经常有这样的业务要处理,服务器上有较多的业务需要处理,需要分批操作,于是就需要一个提 ...
- C#控制台进度条(Programming Progress bar in C# Consle application)
以下代码从Stack Overflow,觉得以后会用到就收藏一下,我是辛勤的搬运工,咿呀咿呀哟- 1.showing percentage in .net console application(在. ...
- Bootstrap 警告、进度条、列表组、面板
摘要:该部分包括警告.进度条.列表组.面板等部分. 1.警告(alert) 1.1 基本的警告(.alert) 警告的基类是 .alert .和其他样式类一块使用.例如: .alert-success ...
- 微信小程序组件解读和分析:六、progress进度条
progress进度条组件说明: 进度条,就是表示事情当前完成到什么地步了,可以让用户视觉上感知事情的执行.progress进度条是微信小程序的组件,和HTML5的进度条progress类似. pro ...
随机推荐
- app.config动态修改及读取
1.添加应用程序配置文件 右键点击项目,选择“添加”→“添加新建项”→“添加应用程序配置文件”将其添加到项目中. 2.设置配置文件 <?xmlversion="1.0"enc ...
- 使用Office2007向cnblogs.com发布文章
步骤: 在cnblogs.com创建一个博客 在office2007中新建->博客文章->创建. 配置帐户:
- smarty 中时间格式化的用法
大家都知道PHP中输出时间和日期可以用 date("Y-m-d H:i:s",时间戳) , 但是在smarty模板中,$time|date_format:'%Y-%m-%d %H ...
- MD5 加密 代码
/*! 获取MD5 加密串 */ +(NSString *)getAuthorization:(NSString *)type Date:(NSDate *)date UserSecret:(NSSt ...
- Qt中如何固定窗口的大小?
这个是从网上转载过来的,我第一次看到的在如下网页:http://blog.csdn.net/cgb0210/article/details/5712980 这里我记录一下,留以后查阅. 一种方法是设 ...
- LeetCode_Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- 【转】VirtualBox direct access to SD Card in Windows--不错
原文网址:http://www.sandyscott.net/2013/08/14/virtualbox-direct-drive-access/ I’ve trying to get my Rasp ...
- Android 查看是否有存储卡插入
String status=Environment.getExternalStorageState(); 2 3 if ( status.equals ( Enviroment.MEDIA_MOU ...
- android 复杂的json数据解析
1.通过谷歌的Gson来进行解析: json数据:sTotalString = {"message":"success","result": ...
- linux image writes boot log to console