Skip to content

Instantly share code, notes, and snippets.

@oliverjanik
Created May 4, 2014 05:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save oliverjanik/a4d49285caa4e9d64dac to your computer and use it in GitHub Desktop.
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