Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- using System.Diagnostics;
- namespace BLConsole
- {
- class Program
- {
- public static Process p;
- static void Main(string[] args)
- {
- AppDomain.CurrentDomain.ProcessExit += new EventHandler(onProcessExit);
- Console.Title = "BL Console";
- p = new Process();
- ProcessStartInfo si = new ProcessStartInfo();
- //Start info properties
- si.FileName = "C:\\Users\\Adam\\Documents\\Blockland\\Blockland.exe";
- si.Arguments = "ptlaaxobimwroe";
- si.UseShellExecute = false;
- si.RedirectStandardOutput = true;
- si.RedirectStandardInput = true;
- si.CreateNoWindow = true;
- si.WindowStyle = ProcessWindowStyle.Hidden;
- p.StartInfo = si;
- p.Start();
- //Start new thread for output
- Thread t = new Thread(OutputThread);
- t.Start();
- //Accept input
- String input = "";
- while(input != "stop")
- {
- input = Console.ReadLine();
- Console.WriteLine("You entered " + input);
- p.StandardInput.WriteLine(input);
- }
- onProcessExit(null, null);
- }
- static void onProcessExit(object sender, EventArgs e)
- {
- p.Kill();
- }
- static void OutputThread()
- {
- while (true)
- {
- while (!p.StandardOutput.EndOfStream)
- {
- Console.WriteLine(p.StandardOutput.ReadLine());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement