SHOW:
|
|
- or go back to the newest paste.
| 1 | static void Main(string[] args) | |
| 2 | {
| |
| 3 | if (args.Length == 0) | |
| 4 | {
| |
| 5 | // Now start another instance and read from it | |
| 6 | ProcessStartInfo info = new ProcessStartInfo(); | |
| 7 | // Set some important properties | |
| 8 | info.RedirectStandardOutput = true; | |
| 9 | info.UseShellExecute = false; | |
| 10 | info.FileName = System.AppDomain.CurrentDomain.FriendlyName; | |
| 11 | // Random arguments string | |
| 12 | info.Arguments = "some arguments to differentiate the 2 usages"; | |
| 13 | // Start the process, wait to end, read from it | |
| 14 | Process process = Process.Start(info); | |
| 15 | process.WaitForExit(); | |
| 16 | Console.WriteLine(process.StandardOutput.ReadToEnd()); | |
| 17 | } | |
| 18 | else | |
| 19 | {
| |
| 20 | // If the process was started with arguments, then run the part that we wish to read from | |
| 21 | - | Console.WriteLine("called with arguments");
|
| 21 | + | Console.WriteLine("I wrote something here what you can read there");
|
| 22 | } | |
| 23 | } |