static async Task Loop(CancellationToken token) { int iterations = 0; var r = new Random(); while (!token.IsCancellationRequested) { try { await Task.Delay(17500 + r.Next(10000), token).ConfigureAwait(false); if (++iterations % 2 == 0) { ChaosHelper.StopRavenDB(); } else { ChaosHelper.KillRavenDB(); } ChaosHelper.StartRavenDB(); } catch (Exception ex) { LogManager.GetLogger <RavenDBChoasEngine>().Warn("Loop", ex); } } }
static void InitAppDomainEventLogging() { ChaosHelper.StartRavenDB(); var firstChanceLog = LogManager.GetLogger("FirstChanceException"); var unhandledLog = LogManager.GetLogger("UnhandledException"); var domain = AppDomain.CurrentDomain; domain.FirstChanceException += (o, ea) => { firstChanceLog.Debug(ea.Exception.Message, ea.Exception); }; domain.UnhandledException += (o, ea) => { var exception = ea.ExceptionObject as Exception; if (exception != null) { unhandledLog.Fatal(exception.Message, exception); } }; }