console-application

first Console.ReadLine() returns immediately

荒凉一梦 提交于 2020-06-23 14:17:50
问题 I am writing a really silly program. I have no idea why the following code won't work: static void Main(string[] args){ <Some silly code> Console.WriteLine("Please choose the lab you are working on:"); int choose = Console.Read(); <Some more silly code, including 1 Console.writeLine() call > Console.WriteLine("Enter the DB server location"); string DBServer = Console.ReadLine(); Console.WriteLine("Enter the DB name"); string DBName = Console.ReadLine(); } When I run the program, it never

Strange issue with SBT, println, and scala console application

懵懂的女人 提交于 2020-06-14 07:55:06
问题 When I run my scala code (I'm using SBT), the prompt is displayed after I enter some text as shown here: C:\... > sbt run [info] Loading project definition [...] [info] Set current project to [...] Running com[...] test >> exit >> >> >> >> >> >> [success] Total time[...] It seems like it's stacking up the print() statements and only displaying them when it runs a different command. If I use println() it works as it should (except that I don't want a newline) The code: ... def main(args:Array

C# console application bring process to foreground

自闭症网瘾萝莉.ら 提交于 2020-05-29 09:10:46
问题 With the following C# console application code, I am able to run the process in background using Jenkins. But now I want to see this process in foreground. What wrong I am doing here ? [System.Runtime.InteropServices.DllImport("User32.dll")] private static extern bool SetForegroundWindow(IntPtr handle); [System.Runtime.InteropServices.DllImport("User32.dll")] private static extern bool ShowWindow(IntPtr handle, int nCmdShow); [System.Runtime.InteropServices.DllImport("User32.dll")] private

Why when compiling .NET Core console application we end up with both dll and exe files?

你说的曾经没有我的故事 提交于 2020-05-16 03:00:10
问题 I have noticed that both dll and exe files with the name of the project are created on Windows when compiling a .NET Core console application. Why is that? In full .Net framework only the exe file would be created. 回答1: Prior to .Net Core 3.0, only the dll was created (although you could still do a single file build that was platform-dependent). In these cases you had to use the command dotnet MyProject.dll to start your program. With .Net Core 3.0, they added the exe , which is still really

Keep threads alive even if console app exits

筅森魡賤 提交于 2020-05-15 10:36:24
问题 I have a console app in C# that runs endlessly and looks something like this: class Program { static void Main(string[] args) { while(true) { var listOfIds = GetItemIds(); Parallel.ForEach(listOfIds, new Parallel { MaxDegreeOfParallelism = 15}, th => DoWork(th)); Console.WriteLine("Iteration Complete"); } } static void DoWork(int id) { //do some work and save data } static List<int> GetItemIds() { //return a list of ints } } While a thread is in DoWork , it is processing data, modifying it

Keep threads alive even if console app exits

断了今生、忘了曾经 提交于 2020-05-15 10:36:11
问题 I have a console app in C# that runs endlessly and looks something like this: class Program { static void Main(string[] args) { while(true) { var listOfIds = GetItemIds(); Parallel.ForEach(listOfIds, new Parallel { MaxDegreeOfParallelism = 15}, th => DoWork(th)); Console.WriteLine("Iteration Complete"); } } static void DoWork(int id) { //do some work and save data } static List<int> GetItemIds() { //return a list of ints } } While a thread is in DoWork , it is processing data, modifying it

Why does my Windows Console Close Event Handler time out?

风流意气都作罢 提交于 2020-05-14 02:28:13
问题 I build the following program in VS2017/Windows 10. When I run it, I hit close and ctrl_handler() is called as expected, but after ~three seconds the process is forcefully terminated anyway. This is a problem because my real application writes large log files and three seconds is not long enough to get them onto disk. Where is the documentation that describes this behaviour? Its not in those for the CTRL+CLOSE signal. Where is the timeout set? Can it be modified at the application level? Or

How to suppress creating of the platform specific executable when building a .Net Core 3.1 console application? [closed]

ぃ、小莉子 提交于 2020-04-17 19:28:25
问题 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 7 days ago . This question is related to Why when compiling .NET Core console application we end up with both dll and exe files? So, how can we suppress the creation of the executable? I am creating a NuGet package from the code and I do not need the executable in the NuGet. 回答1: Prefacing with

How to read what user wrote (without hitting enter) - console C#

拟墨画扇 提交于 2020-03-16 07:03:53
问题 Well, the caption of the question might be a little off, but I didn't figure any better, so here it goes: I would like to read what user typed 'so far', I need it to work like this: User inputs some required data and then is asked if he/she wants the full progress output or just the results. Of course, I could call ReadLine and see what he/she writes, but I'd like to have it neater - after the final data input, he/she would be asked for the detailed info. The program would wait like 2sec and

Socket exception cannot handle by try catch

雨燕双飞 提交于 2020-03-05 05:52:07
问题 I have this console application Asynchronoumus server . Now my problem is after a day or days the application suddenly crashed. but i have try catch every method i have, it seems like that error is not being handled by catch, After looking on logs on application event viewer i have found this error on the day it crushed. Application: CopyChimpServer.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Net.Sockets