console-application

.NET console application as Windows service

浪尽此生 提交于 2019-11-26 14:53:29
I have console application and would like to run it as Windows service. VS2010 has project template which allow to attach console project and build Windows service. I would like to not add separated service project and if possible integrate service code into console application to keep console application as one project which could run as console application or as windows service if run for example from command line using switches. Maybe someone could suggest class library or code snippet which could quickly and easily transform c# console application to service? VladV I usually use the

Console.Read() and Console.ReadLine() problems

假装没事ソ 提交于 2019-11-26 14:38:02
问题 I have been trying to use Console.Read() and Console.ReadLine() in C# but have been getting weird results. for example this code Console.WriteLine("How many students would you like to enter?"); int amount = Console.Read(); Console.WriteLine("{0} {1}", "amount equals", amount); for (int i=0; i < amount; i++) { Console.WriteLine("Input the name of a student"); String StudentName = Console.ReadLine(); Console.WriteLine("the Students name is " + StudentName); } has been giving me that amount = 49

Owin Self host & ASP .Net MVC

孤人 提交于 2019-11-26 14:27:22
问题 I have an ASP .Net MVC app which works just fine under IIS. I need to be able to run the same app from a self hosted console app. How do I do that? Should I use OWIN? What the code should look like? 回答1: Update Now that ASP.NET Core is out there are a few ways to Self Host a web application. One option is to use an OWIN based web server such as Nowin. var host = new WebHostBuilder() .UseNowin() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>() .Build(); Alternatively,

Non-Blocking read from standard I/O in C# [closed]

Deadly 提交于 2019-11-26 14:27:17
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . I want a non-blocking read function from console. How do I write that in C#? 回答1: var buf=new byte[2048]; var inputStream=Console.OpenStandardInput(); //dispose me when you're done inputStream.BeginRead(buf,0,buf

Setting the Cursor Position in a Win32 Console Application

。_饼干妹妹 提交于 2019-11-26 14:15:39
问题 How can I set the cursor position in a Win32 Console application? Preferably, I would like to avoid making a handle and using the Windows Console Functions. (I spent all morning running down that dark alley; it creates more problems than it solves.) I seem to recall doing this relatively simply when I was in college using stdio, but I can't find any examples of how to do it now. Any thoughts or suggestions would be greatly appreciated. Thanks. Additional Details Here is what I am now trying

What is the difference between getch() and getchar()?

南笙酒味 提交于 2019-11-26 12:43:26
问题 What is the exact difference between the getch and getchar functions? 回答1: getchar() is a standard function that gets a character from the stdin. getch() is non-standard. It gets a character from the keyboard (which may be different from stdin) and does not echo it. 回答2: The Standard C function is is getchar() , declared in <stdio.h> . It has existed basically since the dawn of time. It reads one character from standard input ( stdin ), which is typically the user's keyboard, unless it has

Java gotoxy(x,y) for console applications

不打扰是莪最后的温柔 提交于 2019-11-26 12:23:47
I'm writing a simple console application (80x24) in Java, is there a gotoxy(x,y) equivalent? If by gotoxy(x,y), you want to reposition your cursor somewhere specific on the console, you can usually use VT100 control codes to do this. See http://www.termsys.demon.co.uk/vtansi.htm . Do something like char escCode = 0x1B; int row = 10; int column = 10; System.out.print(String.format("%c[%d;%df",escCode,row,column)); Which should move the cursor to position 10,10 on the console. I don't think there's a built-in function to do that in Java. There's a Java curses library called JCurses that you can

How do I launch the Android emulator from the command line?

匆匆过客 提交于 2019-11-26 11:58:16
I'm on Mac, working on Android development from the terminal. I have successfully created the HelloWorld project and now I'm trying to run it from the command line in the Android emulator. Which command runs the emulator for my HelloWorld project? I already have the Android tools and platform-tools in my PATH. Edit: How do I tell the emulator to run my HelloWorld project from the command line? I've already built the project with ant. Malcolm I assume that you have built your project and just need to launch it, but you don't have any AVDs created and have to use command line for all the actions

Global hotkey in console application

戏子无情 提交于 2019-11-26 11:45:58
Does anyone know how to use the RegisterHotKey/UnregisterHotKey API calls in a console application? I assume that setting up/removing the hotkey is the same, but how do I get the call back when the key was pressed? Every example I see is for Winforms, and uses protected override void WndProc(ref Message m){...} , which isn't available to me. update: what I have is below, but the event is never hit. I thought it could be because when you load ConsoleShell it does block further execution, but even if I put SetupHotkey into a different thread nothing happens. Any thoughts? class Program { static

How to fix “No overload for method &#39; &#39; takes 0 arguments”?

情到浓时终转凉″ 提交于 2019-11-26 11:36:36
问题 How can I fix this error? \"No overload for method \'output\' takes 0 arguments\". The error is at the very bottom at \"fresh.output();\". I don\'t know what I\'m doing wrong. Can someone tell me what I should do to fix the code? Here is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication_program { public class Numbers { public double one, two, three, four; public virtual void output(double o, double tw, double th, double