console-application

Windows Console Application Getting Stuck (Needs Key Press) [duplicate]

久未见 提交于 2019-11-27 18:59:50
This question already has an answer here: How and why does QuickEdit mode in Command Prompt freeze applications? 2 answers I have a console program that has different components that run like this: void start() { while(true){ DoSomething(); Thread.Sleep(1000*5); } } My main entry point looks like [pseudo-ish code] Thread.Start(Componenet1.Start); Thread.Start(Componenet2.Start); while(true){ Console.Writeline("running"); Thread.Sleep(1000*5); } There are no Console.Reads anywhere. My problem is SOMETIMES the application will be running great but then stop and if I press any key on the window

System.drawing namespace not found under console application

余生长醉 提交于 2019-11-27 18:18:44
I selected console application as my C# project. But the imports that seemed to work under windows form project doesnt seem to work here. It says that the drawing namespace does not exist. using System.Drawing; using System.Drawing.Imaging; My problem is that i need to have the bitmap class. I am trying to make a command line app that does bitmap manipulations to a image. That's why i didn't chose my project to be a windows form's one. dotnetstep Right click on properties of Console Application. Check Target framework If it is .Net framework 4.0 Client Profile then change it to .Net Framework

How do I wait until a console application is idle?

蓝咒 提交于 2019-11-27 18:17:36
问题 I have a console application that starts up, hosts a bunch of services (long-running startup), and then waits for clients to call into it. I have integration tests that start this console application and make "client" calls. How do I wait for the console application to complete its startup before making the client calls? I want to avoid doing Thread.Sleep(int) because that's dependent on the startup time (which may change) and I waste time if the startup is faster . Process.WaitForInputIdle

Can I write into console in a unit test? If yes, why the console window is not opened?

随声附和 提交于 2019-11-27 17:55:14
I have a test project in Visual Studio. I use Microsoft.VisualStudio.TestTools.UnitTesting. I add this line in one of my unit tests: Console.WriteLine("Some foo was very angry with boo"); Console.ReadLine(); When I run the test, test passes but console window is not opened at all. Is there a way to make the Console window available to be interacted via a unit test? Michael Edenfield NOTE: The original answer below should work for any version of VS up through VS2012. VS2013 does not appear to have a Test Results window anymore. Instead, if you need test-specific output you can use @Stretch's

Why computing factorial of realtively small numbers (34+) returns 0

旧巷老猫 提交于 2019-11-27 16:32:16
int n = Convert.ToInt32(Console.ReadLine()); int factorial = 1; for (int i = 1; i <= n; i++) { factorial *= i; } Console.WriteLine(factorial); This code runs in Console Application, but when a number is above 34 application returns 0. Why 0 is returned and what can be done to compute factorial of large numbers? You're going out of range of what the variable can store. That's effectively a factorial, which grows faster than the exponential. Try using ulong (max value 2^64 = 18,446,744,073,709,551,615) instead of int (max value 2^31 = 2,147,483,647) - ulong p = 1 - that should get you a bit

itextsharp: How to generate a report with dynamic header in PDF using itextsharp?

假如想象 提交于 2019-11-27 16:28:59
I'm generating a PDF report with itextsharp, the header of the report has the information of the Customer, In the body of the report contains a list of customer transactions. My doubt is: How to generate a header dynamically for each client? I need an example to generate a header dynamically to the report. Every new page Header need to have the data that client when changing client header should contain information on the new client. Your question risks down-voting or at least comments in the sense of "What have you tried?" However, I've written you a small example in Java which you can easily

Visual Studio 2017 c++ win32 console project template

南楼画角 提交于 2019-11-27 16:23:40
问题 I am on Visual Studio Community 2017 v. 15.3.1 and I can't seem to find Win32 console application or Win32 project. Still have empty c++ project template and Windows Console Application template. On the start page, I still have win 32 console project available, but if I click it, I get a prompt about removing it from the list EDIT: I have currently installed following Workloads: Universal Windows Platform Net desktop development Desktop development with C++ Game Development with C++ Visual

Edit text in C# console application? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-11-27 15:30:31
This question already has an answer here: C# Advanced Console I/O [duplicate] 4 answers Console.ReadLine(“Default Text Editable Text On Line”) 2 answers Is there a way to edit text in a C# console application? In other words, is it possible to place pre-defined text on the command line so that the user can modify the text and then re-submit it to the app? One thing that came to my mind is to...simulate keystrokes. And a simple example using SendKeys: static void Main(string[] args) { Console.Write("Your editable text:"); SendKeys.SendWait("hello"); //hello text will be editable :) Console

C# Console App + Event Handling

為{幸葍}努か 提交于 2019-11-27 15:20:51
Hey all. I'm trying to see about handling events in a console application. I would prefer to not use silent WinForms (though I understand that that's one way) to do it. I've read over a similar question and its response. See response text below ( link ): The basic requirement of an STA thread is that it needs to run a message pump. In Windows Forms, you can use Application.Run. Or you could write the message pump by hand, using user32!GetMessage & DispatchMessage. But it's probably easier to use the one in WinForms or WPF. What the basic structure of a program that uses "user32 -> GetMessage"

String calculator [closed]

我们两清 提交于 2019-11-27 15:19:40
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Hi fellow programmers, I am creating a calculator in C# and I have a string variable math which contains 100 * 5 - 2 How can I display its output which is 498 in my console? My code is this: String math = "100 * 5 - 2"; Console.WriteLine(math); Console.ReadLine(); // For Pause So