console-application

Trigger background service ExecuteAsync method in .Net core console application

帅比萌擦擦* 提交于 2021-01-24 05:41:55
问题 I am creating console application in asp.net core which is going to run as background service in different environments. I have used " BackgroundService " class provided by " Microsoft.Extensions.Hosting ". I want to run its " ExecuteAsync " method when my program gets started. File: Program.cs public static void Main(string[] args) { var host = new HostBuilder() .ConfigureHostConfiguration(configHost => { }) .ConfigureServices((hostContext, services) => { services.AddHostedService

Smalltalk (Pharo) How to interface with the user simply

南笙酒味 提交于 2021-01-21 08:29:35
问题 I stumbled upon Smalltalk and further downloaded Pharo, because it was recommended. My first impression is very positive. I wanted to port some simple programs I have written in C++ (my main language), so I can get a feel for Smalltalk. However, I realized I can't find a simple way to just get some input from the user, e.g. I want to create a console calculator with a REPL loop, but I can't find a way to do this in Pharo. I don't want a gui with buttons, because that is just slow and

Print out object elements from list

浪子不回头ぞ 提交于 2021-01-13 09:13:16
问题 I'm trying to print object element in my list with foreach loop in main scope, but the only thing that prints out is : ConsoleApplication1.WorldMap What have gone wrong here and how do I get it to print out the actual elements? using ConsoleApplication1; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class WorldMap { private string higher; private string lower; public worldMap

Print out object elements from list

六月ゝ 毕业季﹏ 提交于 2021-01-13 09:13:02
问题 I'm trying to print object element in my list with foreach loop in main scope, but the only thing that prints out is : ConsoleApplication1.WorldMap What have gone wrong here and how do I get it to print out the actual elements? using ConsoleApplication1; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class WorldMap { private string higher; private string lower; public worldMap

Print out object elements from list

妖精的绣舞 提交于 2021-01-13 09:10:12
问题 I'm trying to print object element in my list with foreach loop in main scope, but the only thing that prints out is : ConsoleApplication1.WorldMap What have gone wrong here and how do I get it to print out the actual elements? using ConsoleApplication1; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class WorldMap { private string higher; private string lower; public worldMap

Print document in c# console app

我只是一个虾纸丫 提交于 2021-01-05 06:56:24
问题 I need to print any doc type in console app, i tried using System.Drawing.Printing, but it could not be found in VS. System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument(); 回答1: This worked for me: ProcessStartInfo info = new ProcessStartInfo(filePath); info.Verb = "Print"; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(info); 来源: https://stackoverflow.com/questions/51926369/print-document-in-c-sharp-console

How to use Dependency Injection in .Net core Console Application

て烟熏妆下的殇ゞ 提交于 2020-12-29 03:47:15
问题 I have to add data to my database using a Console Application. In the Main() method I added: var services = new ServiceCollection(); var serviceProvider = services.BuildServiceProvider(); var connection = @"Server = (localdb)\mssqllocaldb; Database = CryptoCurrency; Trusted_Connection = True; ConnectRetryCount = 0"; services.AddDbContext<CurrencyDbContext>(options => options.UseSqlServer(connection)); In another class I add functionality to work with database, and made it like a Web Api

How to use Dependency Injection in .Net core Console Application

泪湿孤枕 提交于 2020-12-29 03:44:34
问题 I have to add data to my database using a Console Application. In the Main() method I added: var services = new ServiceCollection(); var serviceProvider = services.BuildServiceProvider(); var connection = @"Server = (localdb)\mssqllocaldb; Database = CryptoCurrency; Trusted_Connection = True; ConnectRetryCount = 0"; services.AddDbContext<CurrencyDbContext>(options => options.UseSqlServer(connection)); In another class I add functionality to work with database, and made it like a Web Api

Using Console.SetCursorPosition asynchronously

无人久伴 提交于 2020-12-13 03:19:28
问题 To experiment with updating percentages of progress items in the console, I've made a small test console application: using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; namespace ConsoleProgressTest { class Program { public class ConsoleItem { public string Item { get; set; } public int ConsoleLocLeft { get; set; } public int ConsoleLocTop { get; set; } } static void Main(string[] args) { List<string> tempList =

Is there any equivalent of getch() from C++ in Java? [duplicate]

你离开我真会死。 提交于 2020-12-08 07:16:41
问题 This question already has answers here : Equivalent function to C's “_getch()” in Java? (7 answers) Closed 7 years ago . Is there any equivalent to C++’s getch() in Java? That is a function that moves the control forward as soon as a keyboard key is pressed, and also stores the character pressed. I would like to use that function in a console app. 回答1: There's no getch() function equivalent in java. But since you are not the first one who is asking about it, there are some solutions available