Created
May 4, 2014 05:29
-
-
Save oliverjanik/a4d49285caa4e9d64dac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MultiProcessTest | |
{ | |
using System; | |
using System.Diagnostics; | |
using System.Globalization; | |
using System.Linq; | |
using Serilog; | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
if (args.Length == 0) | |
RunMain(); | |
else | |
RunChild(Int32.Parse(args[0])); | |
} | |
private static void RunChild(int i) | |
{ | |
SetupLog(); | |
foreach (var count in Enumerable.Range(0, 10000)) | |
Log.Information("This is logger {number}: {count}", i, count); | |
} | |
private static void SetupLog() | |
{ | |
Log.Logger = new LoggerConfiguration() | |
.WriteTo.RollingFile("log.txt") | |
.CreateLogger(); | |
} | |
private static void RunMain() | |
{ | |
var file = Process.GetCurrentProcess().MainModule.FileName; | |
foreach (var count in Enumerable.Range(0, 5)) | |
Process.Start(file, count.ToString(CultureInfo.InvariantCulture)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment