console-application

Use wc on all subdirectories to count the sum of lines

左心房为你撑大大i 提交于 2019-11-29 00:20:17
问题 How can I count all lines of all files in all subdirectories with wc ? cd mydir wc -l * .. 11723 total man wc suggests wc -l --files0-from=- , but I do not know how to generate the list of all files as NUL-terminated names find . -print | wc -l --files0-from=- did not work. 回答1: You probably want this: find . -type f -print0 | wc -l --files0-from=- If you only want the total number of lines, you could use find . -type f -exec cat {} + | wc -l 回答2: Perhaps you are looking for exec option of

c# console, Console.Clear problem

青春壹個敷衍的年華 提交于 2019-11-28 23:38:59
I am writing a console program in C#. Is there a way I can use a Console.Clear() to only clear certain things on the console screen? Here's my issue: I have a logo (I put it on screen using Console.WriteLine()) and a 2d array which I want to keep constant and clear everything below it. You could use a custom method to clear parts of the screen... static void Clear(int x, int y, int width, int height) { int curTop = Console.CursorTop; int curLeft = Console.CursorLeft; for (; height > 0;) { Console.SetCursorPosition(x, y + --height); Console.Write(new string(' ',width)); } Console

standard way to perform a clean shutdown with Boost.Asio

喜夏-厌秋 提交于 2019-11-28 23:37:41
问题 I'm writing a cross-platform server program in C++ using Boost.Asio. Following the HTTP Server example on this page, I'd like to handle a user termination request without using implementation-specific APIs. I've initially attempted to use the standard C signal library, but have been unable to find a design pattern suitable for Asio. The Windows example's design seems to resemble the signal library closest, but there's a race condition where the console ctrl handler could be called after the

Clear Console Buffer

牧云@^-^@ 提交于 2019-11-28 23:31:56
I'm writing a sample console application in VS2008. Now I have a Console.WriteLine() method which displays output on the screen and then there is Console.ReadKey() which waits for the user to end the application. If I press Enter while the Console.WriteLine() method is displaying then the application exits. How can I clear the input buffer before the Console.ReadKey() method so that no matter how many times the user presses the Enter button while the data is being displayed, the Console.ReadKey() method should stop the application from exiting? while(Console.KeyAvailable) { Console.ReadKey

How to set a console application window to be the top most window (C#)?

无人久伴 提交于 2019-11-28 23:19:43
问题 How do i set a console application to be the top most window. I am building the console application in .NET (i am using C# and maybe even pinvokes to unmanaged code is ok). I thought that i could have my console application derive from Form class class MyConsoleApp : Form { public MyConsoleApp() { this.TopLevel = true; this.TopMost = true; this.CenterToScreen(); } public void DoSomething() { //.... } public static void Main() { MyConsoleApp consoleApp = new MyConsoleApp(); consoleApp

Multiple consoles for a single application C++

妖精的绣舞 提交于 2019-11-28 23:17:23
问题 Is it possible to create two console windows (one being the main) and the secondary being a pop-up like a message box in Windows Forms? I only want the secondary console window to hold IDs (that will be hard coded into the application) So the user does not have to keep returning to the main menu to check available IDs If so how would you go about it? Many Thanks 回答1: Yes, you can do it. The solution is actually very simple - our process can start a new helper child-process, so the helper

Load Assembly in New AppDomain without loading it in Parent AppDomain

百般思念 提交于 2019-11-28 22:42:53
问题 I am attempting to load a dll into a console app and then unload it and delete the file completely. The problem I am having is that the act of loading the dll in its own AppDomain creates a reference in the Parent AppDomain thus not allowing me to destroy the dll file unless I totally shut down the program. Any thoughts on making this code work? string fileLocation = @"C:\Collector.dll"; AppDomain domain = AppDomain.CreateDomain(fileLocation); domain.Load(@"Services.Collector"); AppDomain

How to cleanly shut down a console app started with Process.Start?

非 Y 不嫁゛ 提交于 2019-11-28 22:40:51
问题 This is looking like an impossible task. Absolutely nothing I've found works. The question is how to cleanly close a console application started with Process.Start that has been started with no console window and without using shell execute: ( ProcessStartInfo.CreateNoWindow = true; ProcessStartInfo.UseShellExecute = false; ). It is given that the application being started will shut down "cleanly" if it receives a ctrl-c or ctrl-break signal, but there seems to be no way to send it one that

Wrapping a C# service in a console app to debug it

僤鯓⒐⒋嵵緔 提交于 2019-11-28 22:40:48
I want to debug a service written in C# and the old fashioned way is just too long. I have to stop the service, start my application that uses the service in debug mode (Visual studio 2008), start the service, attach to the service process and then navigate in my Asp.Net application to trigger the service. I basically have the service running in the background, waiting for a task. The web application will trigger a task to be picked up by the service. What I would like to do is to have a console application that fires the service in an effort for me to debug. Is there any simple demo that

Is Thread.Sleep(Timeout.Infinite); more efficient than while(true){}?

旧时模样 提交于 2019-11-28 21:13:09
I have a console application that I would like to keep open all of the time while still listening in to events. I have tested Thread.Sleep(Timeout.Infinite); and while (true) { } and both allow the events to be raised while keeping the console application open. Is there one that I should be using over the other? If the thread is sleeping, is there anything that I should not be doing, such as modifying a static collection declared in the scope of the class? I would recommend using a ManualResetEvent (or other WaitHandle ), and calling ManualResetEvent.WaitOne . This will have a similar effect