How to customize the console applicaton

下面是如何最大化console和改变其显示的字体颜色的代码,顺便包含了计时代码(帮助做性能分析):

    class Program
    {
        [DllImport("kernel32.dll", ExactSpelling = true)]
        private static extern IntPtr GetConsoleWindow();
        private static IntPtr ThisConsole = GetConsoleWindow();

        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        private const int HIDE = 0;
        private const int MAXIMIZE = 3;
        private const int MINIMIZE = 6;
        private const int RESTORE = 9;

        private const int OldestPhaseNo = 2003001;

        static void Main(string[] args)
        {
            // Set maximum console windows size
            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            ShowWindow(ThisConsole, MAXIMIZE);

            // Start the time watch
            Stopwatch watch = new Stopwatch();
            watch.Start();

            // Stop the time wattch
            Dictionary<string, string> ssqRecords = GetSsQiuRecords().Result;
            watch.Stop();

            // Change/Set the console‘s foregound clodr as green
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(watch.Elapsed.TotalSeconds);

            // Restart the time calculation to 0
            watch.Restart();
            SaveLotteryDataToLocalConfig(ssqRecords);
            watch.Stop();

            Console.WriteLine(watch.Elapsed.TotalSeconds);
            // Revert back to the default color
            Console.ForegroundColor = ConsoleColor.Gray;

            // Set the display buffer for console window
            Console.SetBufferSize(1000, 30000);
        }
    }
时间: 2024-12-18 10:28:11

How to customize the console applicaton的相关文章

Hosting Web API in Windows service

Running your api as Windows services can have multiple advantages, especially when working on bigger projects. This allows for multiple (services to run in isolation and gives fine grained control over your system components. ASP.NET Web API ships wi

bin&amp;sbin 命令作用

最近需要了解sbin与bin的功能,需要整理一下.一下全部为Ubuntu14里面默认安装的.在这里收集一下,转载请注明出处! bin bash shell bunzip2 .bz2文件的解压缩程序. busybox BusyBox 是一个集成了一百多个最常用linux命令和工具的软件.BusyBox 包含了一些简单的工具,例如ls.cat和echo等等,还包含了一些更大.更复杂的工具,例grep.find.mount以及telnet. bzcat 指定要显示内容的.bz2压缩文件,并不解压缩 b

groovyConsole — the Groovy Swing console

1. Groovy : Groovy Console The Groovy Swing Console allows a user to enter and run Groovy scripts. This page documents the features of this user interface. 2. Basics Groovy Console is launched via groovyConsole or groovyConsole.bat, both located in $

学习PhoneGap过程遇到的问题1(csp导致行内console和alert失效)

初学PhoneGap,今天鼓捣了一天终于把环境以及如何创建项目搞明白了.首先说说我遇到的问题,我已经通过命令行创建好项目,并且手动加了该用的插件.随后我按照书里介绍的开开心心的敲了如下代码: <script type="text/javascript"> document.addEventListener("deviceready", onDeviceReady, true); function onDeviceReady() { console.log

Configuring Your EMS Server or EMS Console Server on Windows/Linux

EMS Configuration Files RAD Studio provides the scripts to render the web-browser console, the EMS server configuration file and the script to create the EMS database, and the stand-alone applications to run the EMS Console Server and the EMS Server.

【转】console.log 用法

转自http://www.cnblogs.com/ctriphire/p/4116207.html 大家都有用过各种类型的浏览器,每种浏览器都有自己的特色,本人拙见,在我用过的浏览器当中,我是最喜欢Chrome的,因为它对于调试脚本及前端设计调试都有它比其它浏览器有过之而无不及的地方.可能大家对console.log会有一定的了解,心里难免会想调试的时候用alert不就行了,干嘛还要用console.log这么一长串的字符串来替代alert输出信息呢,下面我就介绍一些调试的入门技巧,让你爱上co

Console.WriteLine的小用法

我在一开始使用Console.WriteLine的时候,经常采用的是拼接字符串的形式来构建输出. 但是Console.WriteLine具有扩展的方法来对内容进行输出,类似于我们常用的String.Format. static void Main(string[] args) { //generic list List<int> ListGeneric = new List<int> { 5, 9, 1, 4 }; //timer for generic list sort Sto

【chrome】在做项目使用chrome调试的时候,调整Console的位置

在新的电脑上安装了谷歌浏览器 ,然后在调试系统的时候,发现console这个控制台,模拟调试js的位置无法显示到source以下, 解决问题: 怎么样让console控制台显示到sources下,在查看js源码的同时又能查看console模拟控制台的js调试呢? 在sources界面下,按下ESC按钮,即可!

破解H3C S5120 console密码

使用console登录设备提示为 Username:password: 断电重启设备,按Ctrl + B进入引导程序Starting...... ************************************************************************    *                                                                      *    *               H3C S5120