console-application

Invoking Delegate in a Console Application

情到浓时终转凉″ 提交于 2019-12-11 07:04:27
问题 I need to migrate a WinForm Application to a Console Application. In the WinForm Application, I have something like: this.Invoke(new LogResponseCallback(this.LogResponse), new object[] { allAlarmsJson }); private delegate void LogResponseCallback(string text); private void LogResponse(string response) { this._richTextResponse.Text = response + "\r\n"; } Seems like Main Thread has been called after the processing of a certain operation. My concern is how can the same Asynchronous delegate call

TFS 2015 CI - Build artifacts are not generating for Console application in the solution which has web, console and WCF projects

坚强是说给别人听的谎言 提交于 2019-12-11 07:04:13
问题 I am creating a continuous integration using TFS 2015 CI for a project solution which has combination of Web project, WCF Project , class libraries and Console Applcation. The Project is structured as shown below Project Solution Project 1 (Web UI Project) Project 2 (WCF Project) Project 3 (Console Application-Batch Scheduler) Project 4 ( Class library) Project 5 ( Class library) Project 6 ( Class library) I have added the MSBuild task and included the following arguments , /p:DeployOnBuild

Printing numbers from 1 to 1000 in console application in C#

妖精的绣舞 提交于 2019-12-11 06:57:02
问题 The problem is it only prints from 702 to 1000. What should be the code to print number from 1 to 1000. static void Main(string[] args) { // Console.Write("\tOutput : " + arr[0] + arr[1] + arr[2] + arr[3] + "\n"); //int[] arr = new int[4] { 0, 0, 0, 0 }; for (int i=0; i<=1000; i++) { Console.WriteLine(i); } Console.ReadKey(); } 回答1: You only see the last 300 or so lines because your console window has a limited line buffer. Your code is fine (besides that it also prints 0) as you will see

How to write Unicode characters to the console?

别来无恙 提交于 2019-12-11 06:53:48
问题 I was wondering if it was possible, in a console application, to write characters like ℃ using .NET. When I try to write this character, the console outputs a question mark. 回答1: It's likely that your output encoding is set to ASCII. Try using this before sending output: Console.OutputEncoding = System.Text.Encoding.UTF8; (MSDN link to supporting documentation.) And here's a little console test app you may find handy: C# using System; using System.Text; public static class ConsoleOutputTest {

Building C# console app for multiple instances

这一生的挚爱 提交于 2019-12-11 06:46:22
问题 I'm building a console application which imports data into databases. This is to run every hour depending on an input CSV file being present. The application also needs to be reused for other database imports on the same server, e.g. there could be up to 20 instances of the same .exe file with each instance having their own separate configuration. At the moment I have the base application which passes a location of config file via args, so it can be tweaked depending on which application

Scrolling the scrollbar of a ConsoleApplication hangs the thread

白昼怎懂夜的黑 提交于 2019-12-11 06:37:30
问题 I've got some server apps that I've been trying to get some metrics from so I can debug them. I found that when scrolling back up the window I'd suddenly get timeouts from the clients. Sure enough, moving the scrollbar stopped the application. I'm probably missing something fundemental here, but I can't work out why moving the scrollbar on a Console window would block the thread. It's very simple to reproduce: Sub Main() Do Console.WriteLine(Now.ToString("O")) System.Threading.Thread.Sleep

How to handle NPM/Newman failure/hanging when executed via C# console

故事扮演 提交于 2019-12-11 06:27:33
问题 I have the method created in C# (as below) which executes a few npm/newman commands via C# console-app. The current code handles if the cmd hangs/failed, but it does not handle the case if the nmp/newman execution hangs or fail. Can you please help with this? public string Runner () { var psiNpm = new ProcessStartInfo { FileName = "cmd", RedirectStandardOutput = true, RedirectStandardInput = true, UseShellExecute = false }; var pNpmRun = Process.Start(psiNpm); pNpmRun.StandardInput.WriteLine(

Add a character to the mid of a string that is not always the same

时光总嘲笑我的痴心妄想 提交于 2019-12-11 06:09:49
问题 In my program I need to add a character to my string and then print it on the console. In my case, the number will not be always the same, but will always have 2 characters. I need to add a ' , ' to the mid position, but I don't know how. (I'm very beginner, please post an example code). An example is, I want to turn "25" to "2,5". Thanks for your help. [sorry for bad english, also the title can be pretty bad/misleading] 回答1: Based on your requirement ( will always have 2 characters ) You can

Logger application for c# console application

北城余情 提交于 2019-12-11 05:49:04
问题 I'm designing a console application for the first time in my career. This console application is an engine which will do a task every night at particular time. I'm going to schedule this application using windows task scheduler. Now I need to log every step in this task. I'm not sure what logger best suits for this kind of application. This log messages may be stored to a database, xml or a flat file. Can you give your suggestions for best logger application for this kind of scenario? 回答1:

Getting a console application to allow input multiple times

我怕爱的太早我们不能终老 提交于 2019-12-11 05:48:07
问题 I made a console application that calculates the number of days since a user-specified date. But after the original calculation, if another date is typed in, the application closes. Is there a way I can get my application to not close if the user wants to continue using it? Console.WriteLine("Please enter the date you wish to specify: (DD/MM/YYYY)"); string userInput; userInput = Console.ReadLine(); DateTime calc = DateTime.Parse(userInput); TimeSpan days = DateTime.Now.Subtract(calc);