private PhysicalConsole() { Console.CancelKeyPress += (o, e) => { CancelKeyPress?.Invoke(o, e); }; }
public ConsoleInput() { Name = "ConsoleInput"; backgroundTask = new Task(() => { while (true) { var message = Console.ReadLine(); if (message?.Trim().Length > 0) { if (message == "stop") { CancelKeyPress?.Invoke(null, null); continue; } lock (_syncObj) messageQueue.Add(message); // resetEvent.Set(); } //if (CanRead) //{ // currentMessage = message; //} //else //{ // if (message == "stop") // { // CancelKeyPress?.Invoke(null, null); // } //} } }); backgroundTask.Start(); }
public void AddInput(IInput input) { // Input.SetResetEvent(resetEvent); input.SetQueue(ownQueue); inputs.Add(input); // Input.RegisterEventHandler(CancelKeyPress); input.CancelKeyPress += (sender, args) => CancelKeyPress?.Invoke(sender, args); }
public void RaiseCancelKeyPress() { // See https://github.com/dotnet/corefx/blob/f2292af3a1794378339d6f5c8adcc0f2019a2cf9/src/System.Console/src/System/ConsoleCancelEventArgs.cs#L14 var eventArgs = typeof(ConsoleCancelEventArgs) .GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) .First() .Invoke(new object[] { ConsoleSpecialKey.ControlC }); CancelKeyPress?.Invoke(this, (ConsoleCancelEventArgs)eventArgs); }
//private void OnConnected(TcpSession client) //{ // Console.WriteLine("added client!"); // clients.Add(client); //} public void OnMessage(string message) { if (message?.Trim().Length > 0) { if (message == "stop") { CancelKeyPress?.Invoke(null, null); return; } lock (_syncObj) messageQueue.Add(message); // resetEvent.Set(); } }
static Console() { //Instance = new Console(); SystemConsole.CancelKeyPress += (sender, args) => CancelKeyPress?.Invoke(sender, args); mDefaultError = Error; mDefaultOut = Out; Context = new ConsoleContext(); #if CONSOLE_EXTENSIONS Error = new ConsoleWriter(Context, Error); ContextOut = new ConsoleWriter(Context, Out); Out = ContextOut; #endif }
private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { CancelKeyPress.Invoke(sender, e); }
private void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; CancelKeyPress?.Invoke(this, e); }
private void OnConsoleCancelKeyPress(object sender, ConsoleCancelEventArgs e) { CancelKeyPress.Invoke(sender, e); }
protected virtual void OnCancelKeyPress(object sender, ConsoleCancelEventArgs consoleCancelEventArgs) { CancelKeyPress?.Invoke(sender, consoleCancelEventArgs); }
public Ui() { Console.CursorVisible = false; Console.OutputEncoding = Encoding.Unicode; Console.CancelKeyPress += (sender, args) => CancelKeyPress?.Invoke(sender, args); }
public void RaiseCancelKeyPress() { CancelKeyPress?.Invoke(this, default); }