console-application

Convert Winform App to Console app

有些话、适合烂在心里 提交于 2019-12-01 04:15:00
Is there a quick and dirty way (or a VS Macro) to convert a WinForms app to a Console App? I have a number of these apps that are no longer needed as Winforms apps. I suppose I could create a bunch of new projects and copy paste modules and classes over, but if it's just a matter of removing the single form that I have and editing/deleting a few things, I'd rather do that. You can change the project settings to create a Console Application instead of a Windows Application (just hit Ctrl+Enter on the project in the Solution Window, and make that change). That will compile the application as a

How to include another project Console Application exe in an Asp.Net website?

有些话、适合烂在心里 提交于 2019-12-01 03:51:24
问题 I've got two projects: a .Net 4.0 Console Application and an Asp.Net 4.0 Website (they are in the same solution). Now I'd like to include the console application (its .exe) in the web application, because I need to run it on the server when the user clicks on a certain button. Now I would like to include it in a way that the console application will be updated whenever I recompile the solution, so it stays up to date. So... how can I include my .exe in my web app? Ps. Referencing doesn't work

What makes an app console or Windows Form application?

耗尽温柔 提交于 2019-12-01 03:11:56
[Visual Studio 2008] I created a new project for console application and modified it to look like this: class Program { static void Main (string[] args) { Thread.Sleep (2000); } } Then I created another project for Windows Form application and modified it: static class Program { //[STAThread] commented this line static void Main (string[] args) { //Added args //Commented following lines //Application.EnableVisualStyles (); //Application.SetCompatibleTextRenderingDefault (false); //Application.Run (new Form1 ()); commented this line Thread.Sleep (2000); } } Now I have neither written Console

Changing Console Window's size throws ArgumentOutOfRangeException

时光总嘲笑我的痴心妄想 提交于 2019-12-01 02:13:19
I am trying to set the size of the Console Window in a c# console application. I get an ArgumentOutOfRangeException with this message: The value must be less than the console's current maximum window size of 41 in that dimension. Note that this value depends on screen resolution and the console font. I am using this to set it: Console.WindowHeight = 480; How do you set the Console window's size properly? Soner Gönül From MSDN of Console.WindowHeight property: The height of the console window measured in rows. As you can see, these are not pixels . Just remember, these values can change

Global variable in a static method

∥☆過路亽.° 提交于 2019-12-01 01:29:48
问题 This seems basic but Im finding this quite trivial. Simply how would you recommend setting a global variable with a static class (i.e. console-application)? To give you a little more background the main method is calling some custom eventhandlers that I hope to get / set the variables. Any ideas or suggestions you have is appreciated. 回答1: Simplest way is public static Object MyGlobalVariable; which creates a public static field. A little better is: public static Object MyGlobalVariable { get

How to use await in a parallel foreach?

≡放荡痞女 提交于 2019-12-01 01:26:41
问题 So I sepnt the better part of the night trying to figure this out. I was fortunate to get introduced to the parallel.foreach yesterday and it works like I want it to do except from one detail. I have the following: Parallel.ForEach(data, (d) => { try { MyMethod(d, measurements); } catch (Exception e) { // logg } }); Within the method "MyMethod" I have alot of logic that gets done and most of it is fine but I make api calls where I fetch data and I use async task for this to be able to use

Error 1 Cannot apply indexing with [] to an expression of type 'int'

我是研究僧i 提交于 2019-12-01 00:33:50
I am using Microsoft Visual Studio 2010 and C#. This is a function that is being called form elsewhere in my console program, but I can't seem to get input into the array ipoints . static void GetPoints(int ipoints, string srestaurant) { int index = 0; int iinput; for (index = 0; index < 5; index++) { Console.Write("please enter how many points " + srestaurant[index] + " got : "); iinput = Convert.ToInt32(Console.ReadLine()); while (iinput < 0 && iinput > 20) { Console.Write("please enter how many points " + srestaurant[index] + " got : "); iinput = Convert.ToInt32(Console.ReadLine()); }

Reducing console size

梦想与她 提交于 2019-12-01 00:09:55
I got a problem with changing console size. This is my code: BOOL setConsole(int x, int y) { hStdin = GetStdHandle(STD_INPUT_HANDLE); hStdout = GetStdHandle(STD_OUTPUT_HANDLE); if (hStdin == INVALID_HANDLE_VALUE || hStdout == INVALID_HANDLE_VALUE) { MessageBox(NULL, TEXT("GetStdHandle"), TEXT("Console Error"), MB_OK); return false; } SMALL_RECT windowSize = {0, 0, x-1, y-1}; // Change the console window size: SetConsoleWindowInfo(hStdout, TRUE, &windowSize); COORD c = { x, y}; //Change the internal buffer size: SetConsoleScreenBufferSize(hStdout, c); SetConsoleDisplayMode(hStdout,CONSOLE

Control console application from Windows form application C#

心不动则不痛 提交于 2019-11-30 23:54:26
I have 2 applications. One of them is console application, the other is normal form application - both written in C#. I want to open (hidden from view) the console application form the windows form application and be able to send a command lines to the console application. How can i do that? You can start the background process ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "Myapplication.exe"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; Process process = new Process(); process.StartInfo = startInfo; process.Start(); and after that use the Process

Playing sounds on Console - C#

强颜欢笑 提交于 2019-11-30 23:48:31
I'm writing a Console application on C# and I want to play a sound when I display texts continuously. This is what I've done : static SoundPlayer typewriter = new SoundPlayer("typewriter"); static public void print(string str, int delay) { Thread skipThread = new Thread(skipText); typewriter.PlayLooping(); textgap = delay; foreach (char c in str) { Console.Write(c); if (textgap != 0) Thread.Sleep(textgap); } typewriter.Stop(); } typewriter.wav is imported to my project next to the .cs files and I've selected copy always . When I run this code, an error pops out when starting playing the sound