diff --git a/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.cs b/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.cs index d9c92840973..d67c699b88d 100644 --- a/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.cs +++ b/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.cs @@ -3,31 +3,31 @@ public class Example { - public static void Main() - { - var p = new Process(); - p.StartInfo.UseShellExecute = false; - p.StartInfo.RedirectStandardOutput = true; - string eOut = null; - p.StartInfo.RedirectStandardError = true; - p.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => - { eOut += e.Data; }); - p.StartInfo.FileName = "Write500Lines.exe"; - p.Start(); + public static void Main() + { + var p = new Process(); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + string eOut = null; + p.StartInfo.RedirectStandardError = true; + p.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => + { eOut += e.Data; }); + p.StartInfo.FileName = "Write500Lines.exe"; + p.Start(); - // To avoid deadlocks, use an asynchronous read operation on at least one of the streams. - p.BeginErrorReadLine(); - string output = p.StandardOutput.ReadToEnd(); - p.WaitForExit(); + // To avoid deadlocks, use an asynchronous read operation on at least one of the streams. + p.BeginErrorReadLine(); + string output = p.StandardOutput.ReadToEnd(); + p.WaitForExit(); - Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'"); - Console.WriteLine($"\nError stream: {eOut}"); - } + Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'"); + Console.WriteLine($"\nError stream: {eOut}"); + } } // The example displays the following output: // The last 50 characters in the output stream are: -// ' 49,800.20% -// Line 500 of 500 written: 49,900.20% +// 'ritten: 99,80% +// Line 500 of 500 written: 100,00% // ' // // Error stream: Successfully wrote 500 lines. diff --git a/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.cs b/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.cs index d27f2c10ada..69d041ee319 100644 --- a/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.cs +++ b/snippets/csharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.cs @@ -3,25 +3,25 @@ public class Example2 { - public static void Main() - { - var p = new Process(); - p.StartInfo.UseShellExecute = false; - p.StartInfo.RedirectStandardOutput = true; - p.StartInfo.FileName = "Write500Lines.exe"; - p.Start(); + public static void Main() + { + var p = new Process(); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.FileName = "Write500Lines.exe"; + p.Start(); - // To avoid deadlocks, always read the output stream first and then wait. - string output = p.StandardOutput.ReadToEnd(); - p.WaitForExit(); + // To avoid deadlocks, always read the output stream first and then wait. + string output = p.StandardOutput.ReadToEnd(); + p.WaitForExit(); - Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'"); - } + Console.WriteLine($"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'"); + } } // The example displays the following output: // Successfully wrote 500 lines. // // The last 50 characters in the output stream are: -// ' 49,800.20% -// Line 500 of 500 written: 49,900.20% +// 'ritten: 99,80% +// Line 500 of 500 written: 100,00% // ' diff --git a/snippets/csharp/System.Diagnostics/Process/StandardOutput/write500lines.cs b/snippets/csharp/System.Diagnostics/Process/StandardOutput/write500lines.cs index 99c9dc09cf8..eb4aaff9d01 100644 --- a/snippets/csharp/System.Diagnostics/Process/StandardOutput/write500lines.cs +++ b/snippets/csharp/System.Diagnostics/Process/StandardOutput/write500lines.cs @@ -1,20 +1,22 @@ using System; -using System.IO; public class Example3 { - public static void Main() - { - for (int ctr = 0; ctr < 500; ctr++) - Console.WriteLine($"Line {ctr + 1} of 500 written: {ctr + 1/500.0:P2}"); + public static void Main() + { + for (int ctr = 0; ctr < 500; ctr++) + Console.WriteLine($"Line {ctr + 1} of 500 written: {(ctr + 1) / 500.0:P2}"); - Console.Error.WriteLine("\nSuccessfully wrote 500 lines.\n"); - } + Console.Error.WriteLine("\nSuccessfully wrote 500 lines.\n"); + } } // The example displays the following output: -// The last 50 characters in the output stream are: -// ' 49,800.20% -// Line 500 of 500 written: 49,900.20% -//' +// Line 1 of 500 written: 0,20% +// Line 2 of 500 written: 0,40% +// Line 3 of 500 written: 0,60% +// ... +// Line 498 of 500 written: 99,60% +// Line 499 of 500 written: 99,80% +// Line 500 of 500 written: 100,00% // -// Error stream: Successfully wrote 500 lines. +// Successfully wrote 500 lines. diff --git a/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.fs b/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.fs index 3c7a78fd6c9..e67477d110a 100644 --- a/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.fs +++ b/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-async.fs @@ -21,8 +21,8 @@ printfn $"The last 50 characters in the output stream are:\n'{output.Substring(o printfn $"\nError stream: {eOut}" // The example displays the following output: // The last 50 characters in the output stream are: -// ' 49,800.20% -// Line 500 of 500 written: 49,900.20% +// 'ritten: 99,80% +// Line 500 of 500 written: 100,00% // ' // // Error stream: Successfully wrote 500 lines. diff --git a/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.fs b/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.fs index e01ab27ddcb..d2bfa3ce495 100644 --- a/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.fs +++ b/snippets/fsharp/System.Diagnostics/Process/StandardOutput/stdoutput-sync.fs @@ -15,8 +15,7 @@ p.WaitForExit() printfn $"The last 50 characters in the output stream are:\n'{output.Substring(output.Length - 50)}'" // The example displays the following output: // Successfully wrote 500 lines. -// // The last 50 characters in the output stream are: -// ' 49,800.20% -// Line 500 of 500 written: 49,900.20% +// 'ritten: 99,80% +// Line 500 of 500 written: 100,00% // ' diff --git a/snippets/fsharp/System.Diagnostics/Process/StandardOutput/write500lines.fs b/snippets/fsharp/System.Diagnostics/Process/StandardOutput/write500lines.fs index 5053af9903a..f4861ff1dd1 100644 --- a/snippets/fsharp/System.Diagnostics/Process/StandardOutput/write500lines.fs +++ b/snippets/fsharp/System.Diagnostics/Process/StandardOutput/write500lines.fs @@ -5,9 +5,11 @@ for i in 1. .. 500. do eprintfn "Successfully wrote 500 lines."; // The example displays the following output: -// The last 50 characters in the output stream are: -// ' 49,800.20% -// Line 500 of 500 written: 49,900.20% -//' -// -// Error stream: Successfully wrote 500 lines. +// Line 1 of 500 written: 0,20% +// Line 2 of 500 written: 0,40% +// Line 3 of 500 written: 0,60% +// ... +// Line 498 of 500 written: 99,60% +// Line 499 of 500 written: 99,80% +// Line 500 of 500 written: 100,00% +// Successfully wrote 500 lines. diff --git a/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb b/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb index 732372ec04b..8276e0db08c 100644 --- a/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb +++ b/snippets/visualbasic/api/system.diagnostics/process/standardoutput/Write500Lines.vb @@ -3,16 +3,19 @@ Public Module Example Public Sub Main() For ctr As Integer = 0 To 499 - Console.WriteLine($"Line {ctr + 1} of 500 written: {ctr + 1/500.0:P2}") + Console.WriteLine($"Line {ctr + 1} of 500 written: {(ctr + 1) / 500.0:P2}") Next Console.Error.WriteLine($"{vbCrLf}Successfully wrote 500 lines.{vbCrLf}") End Sub End Module ' The example displays the following output: -' The last 50 characters in the output stream are: -' ' 49,800.20% -' Line 500 of 500 written: 49,900.20% +' Line 1 of 500 written 0,20% +' Line 2 of 500 written: 0,40% +' Line 3 of 500 written: 0,60% +' ... +' Line 498 of 500 written: 99,60% +' Line 499 of 500 written: 99,80% +' Line 500 of 500 written: 100,00% ' -' -' Error stream: Successfully wrote 500 lines. \ No newline at end of file +' Successfully wrote 500 lines. \ No newline at end of file diff --git a/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb b/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb index 7b97b386dbe..694ae267333 100644 --- a/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb +++ b/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-async.vb @@ -22,8 +22,8 @@ Public Module Example End Module ' The example displays the following output: ' The last 50 characters in the output stream are: -' ' 49,800.20% -' Line 500 of 500 written: 49,900.20% +' 'ritten: 99,80% +' Line 500 of 500 written: 100,00% ' ' ' ' Error stream: Successfully wrote 500 lines. \ No newline at end of file diff --git a/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb b/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb index caf73c65e69..5e0f9f7932a 100644 --- a/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb +++ b/snippets/visualbasic/api/system.diagnostics/process/standardoutput/stdoutput-sync.vb @@ -19,6 +19,6 @@ End Module ' Successfully wrote 500 lines. ' ' The last 50 characters in the output stream are: -' ' 49,800.20% -' Line 500 of 500 written: 49,900.20% +' 'ritten: 99,80% +' Line 500 of 500 written: 100,00% ' ' \ No newline at end of file