Beispiel #1
0
        private static void RunReader(string filename, int maxLogsPerSec)
        {
            Console.WriteLine($"Monitoring {filename}");
            using (var p = new LogReader(filename)) {
                var aggregator = new LogAggregator(p, maxLogsPerSec);
                aggregator.AggregateProcessed += (sender, agg) => WriteStatus(agg);
                aggregator.AlertTriggered     += (sender, agg) => WriteAlertTriggered(agg);
                aggregator.AlertCancelled     += (sender, agg) => WriteAlertCancelled(agg);

                var cts = new System.Threading.CancellationTokenSource();
                var t   = p.ReadFile(cts.Token);
                t.Wait(cts.Token);
            }
        }
Beispiel #2
0
 private static void RunDemo(string filename, int delay, int maxLogsPerSec)
 {
     Console.WriteLine($"Demoing with {filename}");
     using (var g = new LogWriter(filename, delay))
         using (var p = new LogReader(filename)) {
             var aggregator = new LogAggregator(p, maxLogsPerSec);
             aggregator.AggregateProcessed += (sender, agg) => WriteStatus(agg);
             aggregator.AlertTriggered     += (sender, agg) => WriteAlertTriggered(agg);
             aggregator.AlertCancelled     += (sender, agg) => WriteAlertCancelled(agg);
             var cts = new System.Threading.CancellationTokenSource();
             var tr  = p.ReadFile(cts.Token);
             var tw  = g.WriteFile(cts.Token);
             Task.WaitAll(tw, tr);
         }
 }