private static Task PressEscToExit(ConsoleMessageHandler handler) { return(Task.Run(() => { SystemConsole.WriteLine(@"Press: P to print processed message count C to clear screen R to reset counter ESC to exit"); ConsoleKey key; while ((key = SystemConsole.ReadKey(true).Key) != ConsoleKey.Escape) { switch (key) { case ConsoleKey.C: handler.Clear(); continue; case ConsoleKey.R: handler.Reset(); continue; case ConsoleKey.P: SystemConsole.WriteLine(handler.GetCount()); continue; } } })); }
static void Main(string[] args) { var service = new PhBService(); Console.WriteLine("Start programm"); service.DeleteDb(); Person person1 = new Person { PersonId = 1, Name = "Alex", PhoneNumber = "12345" }; service.AddPerson(person1); var persons = service.GetPeople(); foreach (var person in persons) { Console.WriteLine(person.Name); Console.WriteLine(person.PhoneNumber); } Console.WriteLine("End programm"); Console.ReadKey(); }
public static string ReadPassword() { string pass = ""; do { ConsoleKeyInfo key = OriginalConsole.ReadKey(true); // Backspace Should Not Work if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter) { pass += key.KeyChar; lock (threadLock) OriginalConsole.Write("*"); } else { if (key.Key == ConsoleKey.Backspace && pass.Length > 0) { pass = pass.Substring(0, (pass.Length - 1)); lock (threadLock) OriginalConsole.Write("\b \b"); } else if (key.Key == ConsoleKey.Enter) { break; } } } while (true); lock (threadLock) OriginalConsole.WriteLine(""); return(pass); }
static void Main(string[] _args) { MainProgram p = new MainProgram(); p.Run(); IO.ReadKey(); }
public static void Main(string[] args) { //initialise L.Config .WriteTo.PoshConsole() .WriteTo.AzureApplicationInsights("13d9faf0-e96d-46ce-81b1-d8303c798765", new WriterOptions { FlushOnWrite = false, EnableQuickPulse = true }) .CollectPerformanceCounters.PlatformDefault() .CollectPerformanceCounters .WindowsCounter("Machine CPU Load (%)", "Processor", "% Processor Time", "_Total") .CollectPerformanceCounters .WithSamplingInterval(TimeSpan.FromSeconds(10)); using (L.Context("one", "two")) { log.Trace("just a test"); } C.ReadKey(); return; while (true) { //Basics(5); ApplicationMap(); Thread.Sleep(TimeSpan.FromSeconds(1)); } }
//VD02 static void Main6(string[] arg) { int Row = 20; int Col = 50; char drawChar = '@'; char insideChar = '.'; int curRow = 1; int curCol = 1; do { curCol = 1; do { //Code here if (curRow == 1 || curCol == 1 || curRow == Row || curCol == Col) { C.Write("@"); } else { C.Write("."); } curCol++; } while (curCol <= Col); C.WriteLine(); curRow++; }while (curRow <= Row); C.ReadKey(); }
static void Main(string[] args) { int[][] arr = new int[3][]; arr[0] = new int[3]; arr[1] = new int[2]; arr[2] = new int[1]; D.WriteLine("Enter Elements :"); for (int i = 0; i < 3; i++) { for (int j = 0; j < arr[i].Length; j++) { arr[i][j] = 0; //arr[i][j] = Convert.ToInt32(D.ReadLine()); } } D.WriteLine("Entered Elements are :"); for (int i = 0; i < 3; i++) { for (int j = 0; j < (arr[i].Length); j++) { D.Write(arr[i][j]); D.Write('\t'); } D.WriteLine(); } D.ReadKey(); }
private static async void StartPipeline() { var fName = new BlockingCollection <string>(); var lines = new BlockingCollection <string>(); var words = new ConcurrentDictionary <string, int>(); var items = new BlockingCollection <Info>(); var colouredItems = new BlockingCollection <Info>(); Task s1 = PipelineStage.ReadFileNameAsync(@"../../..", fName); ConsHelper.WriteLine($"Started Stage 1"); Task s2 = PipelineStage.LoadContentAsync(fName, lines); ConsHelper.WriteLine($"Started Stage 2"); Task s3 = PipelineStage.ProcessContentAsync(lines, words); ConsHelper.WriteLine($"Started Stage 3"); await Task.WhenAll(s1, s2, s3); ConsHelper.WriteLine("All stages 1,2,3 have completed"); Task t4 = PipelineStage.TransferContentAsync(words, items); Task t5 = PipelineStage.AddColourAsync(items, colouredItems); await Task.WhenAll(t4, t5); ConsHelper.WriteLine("Stages 4 and 5 completed."); Task tf = PipelineStage.ShowContentAsync(colouredItems); Cons.ReadKey(); }
static void Main(string[] args) { if (!MessageQueue.Exists($@"{Environment.MachineName}\Private$\FromSql")) { MessageQueue.Create($@"{Environment.MachineName}\Private$\FromSql", true); } MessageQueue rQueue = new MessageQueue($@"{Environment.MachineName}\Private$\FromSql"); rQueue.Formatter = new XmlMessageFormatter(new[] { typeof(string) }); rQueue.UseJournalQueue = true; foreach (var file in Directory.EnumerateFiles(@"c:\MSMQ_transport_xmls")) { rQueue.Send(File.ReadAllText(file), MessageQueueTransactionType.Single); } //SqlQueSender.Send($@"{Environment.MachineName}\Private$\Test", "message " + DateTime.Now.ToString(), 7, 4); //SqlQueSender.SendSimple($@"{Environment.MachineName}\Private$\TestQUE", "message " + DateTime.Now.ToString()); Console.WriteLine("Send all"); Console.WriteLine($@"{Environment.MachineName}\Private$\FromSql message count: " + SqlQueSender.CountMessageOnQue($@"{Environment.MachineName}\Private$\FromSql")); Console.WriteLine($@"{Environment.MachineName}\DeadLetter$ message count: " + SqlQueSender.CountMessageOnQue($@"FormatName:DIRECT=OS:{Environment.MachineName}\System$;Deadletter")); Console.WriteLine($@"{Environment.MachineName}\DEADXACT message count: " + SqlQueSender.CountMessageOnQue($@"FormatName:DIRECT=OS:{Environment.MachineName}\System$;Deadxact")); Console.ReadKey(); }
// SecureString is recommended to not be used, see platform-compat/DE0001 public string ReadPassword(string username) { IO.WriteLine($"Please enter the Github password for {username}"); var password = new StringBuilder(); ConsoleKeyInfo keyInfo; do { // true intercepts the keypress, effectively masking the password keyInfo = IO.ReadKey(true); if (keyInfo.Key == ConsoleKey.Backspace) { if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) { password.Clear(); } else { password.Remove(password.Length - 1, 1); } } // for all other cases password.Append(keyInfo.KeyChar); } while (keyInfo.Key != ConsoleKey.Enter); IO.WriteLine(); return(password.ToString()); }
public static void Main(string[] args) { Cons.WriteLine($"Start Chapter 13 Asynchronus Programming"); AFoundationsOfAsync.GetGreetingAs("Dave"); AFoundationsOfAsync.CallerWithContinuation("Caroline"); Cons.Write("Tick."); while (AFoundationsOfAsync._result == null) { Cons.Write("."); Thread.Sleep(500); } Cons.WriteLine("Phew!"); Cons.WriteLine($"What _result is: {AFoundationsOfAsync._result}"); AFoundationsOfAsync.MultiAsCalls("Dick", "Tracey"); AFoundationsOfAsync.ConvAsyncPattern(); //Looking at error handling. AFoundationsOfAsync.DontHandle(); AFoundationsOfAsync.CanHandle(); Cons.Write("....Press Key To Exit!"); Cons.ReadKey(); }
private static int Main(string[] args) { if (bool.TryParse(Environment.GetEnvironmentVariable("SNS_DISABLE_CONSOLE_SIGNING"), out var disabled) && disabled) { PrintMessageColor(".NET Assembly Strong-Name Signer is disabled via the SNS_DISABLE_CONSOLE_SIGNING environment variable.", LogLevel.Default, ConsoleColor.Red); return(0); } try { var parsed = Args.Parse <Options>(args); if (args.Length == 0 || parsed?.Help != false) { PrintHeader(); ArgUsage.GenerateUsageFromTemplate(typeof(Options)); } else { parsed.Validate(); currentLogLevel = parsed.LogLevel; if (currentLogLevel <= LogLevel.Verbose) { PrintHeader(); } var stats = SignAssemblies(parsed); PrintMessage(null, LogLevel.Summary); PrintMessage(".NET Assembly Strong-Name Signer Summary", LogLevel.Summary); PrintMessage(string.Format("{0} file(s) were strong-name signed.", stats.NumberOfSignedFiles), LogLevel.Summary); PrintMessage(string.Format("{0} references(s) were fixed.", stats.NumberOfFixedReferences), LogLevel.Summary); } } catch (ArgException ex) { PrintMessageColor(ex.Message, LogLevel.Silent, ConsoleColor.Red); ArgUsage.GenerateUsageFromTemplate(typeof(Options)); return(2); } catch (Exception ex) { PrintMessageColor(ex.ToString(), LogLevel.Silent, ConsoleColor.Red); return(1); } finally { if (Debugger.IsAttached) { C.ReadKey(true); } } return(0); }
private static void pause_execution_if_debug() { #if DEBUG Console.WriteLine("Press enter to continue..."); Console.ReadKey(); #endif }
ParanoiaChoice GetPlayerChoice() { ParanoiaChoice theChoice = null; while (theChoice == null) { printChoices(); ConsoleKey cki = C.ReadKey(true).Key; if (cki == ConsoleKey.Q) { // quit } else if (cki == ConsoleKey.P) { // Display Player Information } else { int pr = KeyToInt(cki); if (pr > -1 && pr < currentResponse.Choices.Length) { theChoice = currentResponse.Choices [pr]; } } } return(theChoice); }
private static void FarmWork() { Console.WriteLine("Great job! despite the weird looks " + "\n you have been getting from the animals recently you finished all the chores"); Console.ReadKey(); MainMenu(); }
static void Main(string[] args) { //DisposClass dis = new DisposClass(); //using (dis) //{ // Console.WriteLine("using block"); //} //Console.WriteLine("outside using block"); using (DisposClass dis = new DisposClass(), dis2 = new DisposClass()) { K.WriteLine("using bloguu"); //dis.Dispose(); } //Point2D p2 = new Point2D(); //Point3D p3 = new Point3D(); NestedNamesoacesExamp nesObj = new NestedNamesoacesExamp(); Namespace3.InnerClass inObj = new Namespace3.InnerClass(); Namespace3.Namespace4.InInnerClass ininnerObj = new Namespace3.Namespace4.InInnerClass(); InnerClass inObgfj = new InnerClass(); //added using NameSpaces2.Namespace3 ; K.ReadKey(); }
private static void Main(string[] args) { /* Client * using (var client = new TcpClient()) * { * client.ProtocolFactory = WebSocketClientFactory.Default; * client.ConnectTimeout = 15000; * client.WaitTimeout = 15000; * client.Open(new IPEndPoint(IPAddress.Loopback, 6002)); * var resp = (string)client.ExecuteSync("abcdefg"); * resp.Dump(); * } */ using (var server = new TcpServer()) { server.ProtocolFactory = CustomSelectorProcessor.Instance; server.MessageProcessor = CustomMessageProcessor.Instance; server.ConnectionTimeoutSeconds = 60; server.Received += msg => { var conn = (WebSocketConnection)msg.Connection; var reply = (string)msg.Value + " / " + conn.Host; Console.WriteLine("[server] {0}", msg.Value); msg.Connection.Send(msg.Context, reply); }; server.Start("abc", new IPEndPoint(IPAddress.Loopback, 6002)); Console.WriteLine("Server running"); Console.ReadKey(); } Console.WriteLine("Server dead; press any key"); Console.ReadKey(); }
static void Main(string[] args) { HeyoVirtualFile.VirtualFileSystem.ReleaseLib(); int pid = -1; //pid = int.Parse(Console.ReadLine()); while (pid == -1) { Process[] localByName = Process.GetProcessesByName("java"); if (localByName.Length > 0) { pid = localByName[0].Id; } } HeyoVirtualFile.VirtualFileSystem vfs = new HeyoVirtualFile.VirtualFileSystem(pid); vfs.Run(); vfs.AddPuppetFile(new FileMapping(@"D:\Virtual\Test.txt", @"D:\Virtual.txt")); vfs.AddPuppetFile(new FileMapping(@"D:\Virtual\Test666.txt", @"D:\Virtual.txt")); Console.WriteLine("Inject Success"); Console.WriteLine("现在你可以添加虚拟文件,输入格式: 实际文件路径 虚拟文件路径"); while (true) { string actual = Console.ReadLine(); string vir = Console.ReadLine(); vfs.AddPuppetFile(new FileMapping(vir, actual)); Console.WriteLine("添加成功"); } Console.ReadKey(); }
public static string ReadUntilProvidedProtected(string prompt) { string res = ""; while (string.IsNullOrWhiteSpace(res)) { Yellow(prompt); ConsoleKeyInfo key; do { key = C.ReadKey(true); // Backspace Should Not Work if (key.Key != ConsoleKey.Backspace) { res += key.KeyChar; C.Write("*"); } else { C.Write("\b"); } } // Stops Receving Keys Once Enter is Pressed while (key.Key != ConsoleKey.Enter); } C.WriteLine(); return(res.Trim()); }
public void PrintErrorMessage(Exception exception) { SysConsole.WriteLine(ERROR_MESSAGE); SysConsole.WriteLine(ERROR_TEXT_MESSAGE); SysConsole.WriteLine(exception.Message); SysConsole.ReadKey(); }
static void Main(string[] args) { try { Funciones.Error(); } catch (Exception ex) { SC.WriteLine("Ocurrió un error, Conmuniquese con el Administrador"); SC.ReadKey(); using (StreamWriter EscritorDeErrores = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Errores.txt", true)) { EscritorDeErrores.Write(ex.Message); // Objetos arbitrarios tambien pueden ser escritos en el archivo. EscritorDeErrores.Write("lA FECHA ES: "); EscritorDeErrores.WriteLine(DateTime.Now); } } finally { SC.WriteLine("Termino la aplicación..."); SC.ReadKey(); } }
private static string ReadSecureLine() { var input = string.Empty; while (true) { var i = Con.ReadKey(true); if (i.Key == ConsoleKey.Enter) { break; } else if (i.Key == ConsoleKey.Backspace) { if (input.Length > 0) { input = input.Remove(input.Length - 1); Con.Write("\b \b"); } } else { input = string.Concat(input, i.KeyChar); Con.Write("*"); } } return(input); }
private static void Update() { if (SysCon.KeyAvailable) { ConsoleKeyInfo key = SysCon.ReadKey(true); CurrentScreen.Input(key); } }
private void EditLoop() { while (!_done) { ConsoleModifiers mod; var cki = C.ReadKey(true); if (cki.Key == ConsoleKey.Escape) { cki = C.ReadKey(true); mod = ConsoleModifiers.Alt; } else { mod = cki.Modifiers; } var handled = false; foreach (var handler in _handlers) { var t = handler.KeyInfo; if (t.Key == cki.Key && t.Modifiers == mod) { handled = true; handler.KeyHandler(); _lastHandler = handler.KeyHandler; break; } if (t.KeyChar == cki.KeyChar && t.Key == ConsoleKey.Zoom) { handled = true; handler.KeyHandler(); _lastHandler = handler.KeyHandler; break; } } if (handled) { if (_searching != 0) { if (_lastHandler != CmdReverseSearch) { _searching = 0; SetPrompt(Prompt); } } continue; } if (cki.KeyChar != (char)0) { HandleChar(cki.KeyChar); } } }
static void Main(string[] args) { int[,] result = new int[5, 5]; for (int i = 0; i < 5; i++) { D.WriteLine("Enter RollNo and Marks of Student " + (i + 1) + " :"); result[i, 0] = Convert.ToInt32(D.ReadLine()); result[i, 1] = Convert.ToInt32(D.ReadLine()); result[i, 2] = Convert.ToInt32(D.ReadLine()); result[i, 3] = Convert.ToInt32(D.ReadLine()); } D.WriteLine("\n\nTotal Marks Obtained By each Student:"); for (int i = 0; i < 5; i++) { D.Write("Student " + result[i, 0] + " : "); int total = 0; total = result[i, 1] + result[i, 2] + result[i, 3]; result[i, 4] = total; D.Write(total); D.WriteLine(); } //highest mark thing D.WriteLine("\n\nHighest Mark in Each Subject:"); for (int i = 1; i <= 3; i++) { D.Write("Subject " + i + " : "); int high = result[0, i]; int highroll = result[0, 0]; for (int j = 1; j < 5; j++) { if (high < result[j, i]) { high = result[j, i]; highroll = result[j, 0]; } } D.Write(" High Marks : " + high + " Roll No : " + highroll); D.WriteLine(); } //high total thing int hightot = result[0, 4]; int hightotroll = result[0, 0]; for (int i = 1; i < 5; i++) { if (hightot < result[i, 4]) { hightot = result[i, 4]; hightotroll = result[i, 0]; } } D.WriteLine("\n\nThe highest total of marks is " + hightot + " obtained by roll number " + hightotroll); D.ReadKey(); }
public void T() { int HE = 100, M = 100, F = 10, HU = 0, S = 0, P = 0; Action w = () => { X.Clear(); X.WriteLine(string.Format("Health: {0}\r\nMoney: {1}\r\nFood: {2}\r\nHunger: {3}\r\nSleep: {4}\r\nPotions: {5}\r\n", HE, M, F, HU, S, P)); }; while (HE > 0) { if (X.KeyAvailable) { var i = X.ReadKey(); if (i.Key == Y.F) { F -= F > 0 ? 1 : 0; HU -= HU > 8 && F > 0 ? 9 : 0; w(); } if (i.Key == Y.S) { S = 0; w(); } if (i.Key == Y.P) { HE += P > 0 ? 9 : 0; P -= P > 0 ? 1 : 0; w(); } if (i.Key == Y.B) { P += M > 9 ? 1 : 0; M -= M > 8 ? 9 : 0; w(); } if (i.Key == Y.T) { F += M > 8 ? 1 : 0; M -= M > 8 ? 9 : 0; w(); } } HU++; S++; HE -= HU >= 80 ? 1 : 0; HU += S >= 80 ? 9 : 0; S = S >= 80 ? 0 : S; M += HE >= 80 ? 1 : 0; System.Threading.Thread.Sleep(500); w(); } }
private static void Overthrow() { Console.WriteLine("The animals have risen against you, nowhere is safe. It’s time to leave " + "\n you run down the street as you hear the animals chanting " + "\n \"four legs good, two legs bad\" over and over……there is no returning, everything is lost."); Console.ReadKey(); Console.Clear(); MainMenu(); }
static void MainTSS(string[] args) { // Buffer Observable.Range(1, 100) .Buffer(5 /*, 3*/) // elements to skip on subsequent operation // skip value can exceed buffer size, causing // elements to be dropped .Subscribe(x => Console.WriteLine($"Got a group of {x.Count} elements: " + string.Join(",", x)) ); // Delay - simply time-shifts the sequence var source = Observable.Interval(TimeSpan.FromSeconds(1)) .Take(3); var delay = source.Delay(TimeSpan.FromSeconds(2)); source.Timestamp().Inspect("source"); delay.Timestamp().Inspect("delay"); Thread.Sleep(10000); // Sample - takes the last value that was available in a given timespan var samples = Observable.Interval(TimeSpan.FromSeconds(0.5)) .Take(20) .Sample(TimeSpan.FromSeconds(1.75)); samples.Inspect("Sample"); samples.ToTask().Wait(); // Throttle - just like Sample, but the wait window is reset // needs to run in Debug mode (external window) var subj = new Subject <string>(); subj // also Timeout, which causes an exception if nothing happens in X seconds .Timeout(TimeSpan.FromSeconds(3), // this argument alone would throw Observable.Empty <string>()) // this prevents throwing //.Throttle(TimeSpan.FromSeconds(1)) .TimeInterval() .Inspect("Throttle"); string input = string.Empty; ConsoleKeyInfo c; while ((c = Console.ReadKey()).Key != ConsoleKey.Escape) { if (char.IsLetterOrDigit(c.KeyChar)) { input += c.KeyChar; subj.OnNext(input); } else if (c.Key == ConsoleKey.Backspace && input.Length > 0) { input = input.Substring(0, input.Length - 1); } } }
static void Main(string[] args) { try { File.OpenText(Environment.CurrentDirectory + "\\spawn.txt"); } catch { Console.WriteLine("File doesn't exist"); Console.WriteLine("^F[^1ERROR^F]: ^CSpawn position is not set!^R"); return; } try { string[] buf = File.ReadAllText(Environment.CurrentDirectory + "\\spawn.txt").Split(';'); spawnPosition = new OakVec3(float.Parse(buf[0]), float.Parse(buf[1]), float.Parse(buf[2])); } catch { Console.WriteLine("Something f****d up"); Console.WriteLine("^F[^1ERROR^F]: ^CSpawn position is not set!^R"); return; } var iStdOut = GetStdHandle(STD_OUTPUT_HANDLE); if (!GetConsoleMode(iStdOut, out uint outConsoleMode)) { Console.WriteLine("Failed to get output console mode"); SysCon.ReadKey(); return; } outConsoleMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN; if (!SetConsoleMode(iStdOut, outConsoleMode)) { Console.WriteLine($"Failed to set output console mode, error code: {GetLastError()}"); SysCon.ReadKey(); return; } OakwoodEvents.OnLog += OnLog; OakwoodEvents.OnPlayerConnect += OnPlayerConnect; OakwoodEvents.OnPlayerDisconnect += OnPlayerDisconnect; OakwoodEvents.OnPlayerDeath += OnPlayerDeath; OakwoodEvents.OnPlayerChat += OnPlayerChat; OakwoodEvents.OnPlayerKeyDown += OnPlayerKeyDown; Console.WriteLine($"^9Oakwood ^Fposition tool^R"); Console.WriteLine($"^FMade by ^ESevenisko^R"); SysCon.WriteLine(); Thread clThread = new Thread(() => Oakwood.CreateClient("ipc://oakwood-inbound", "ipc://oakwood-outbound")); clThread.Start(); }
private static void FeedChickens() { Console.WriteLine("The chickens have been fed and return to their Coops. " + "\n They silently judge your life decisions and talk about you when you're gone " + "\n They know your weaknesses and fears, they are the enemy of the proud and the " + "\n harbingers of judgment....do not underestimate them"); Console.ReadKey(); Console.Clear(); MainMenu(); }