public static MeterMetric New(string eventType, TimeUnit rateUnit) { var meter = new MeterMetric(eventType, rateUnit); Task.Factory.StartNew(async() => { while (!meter._token.IsCancellationRequested) { await Task.Delay(Interval, meter._token.Token); meter.Tick(); } }, meter._token.Token); return(meter); }
public static MeterMetric New(string eventType, TimeUnit rateUnit) { var meter = new MeterMetric(eventType, rateUnit); Task.Factory.StartNew(() => { while (!meter._token.IsCancellationRequested) { Thread.Sleep(Interval); meter.Tick(); } }, meter._token.Token); return meter; }
public static MeterMetric New(string eventType, TimeUnit rateUnit) { var meter = new MeterMetric(eventType, rateUnit); meter._tickThread = _factory.New( ()=> { new Timer(s => meter.Tick(), null, _interval, _interval); } ); meter._tickThread.Start(); return meter; }
public static MeterMetric New(string eventType, TimeUnit rateUnit) { var meter = new MeterMetric(eventType, rateUnit); meter._token = Utils.StartCancellableTask(() => { while (!meter._token.IsCancellationRequested) { Thread.Sleep(Interval); meter.Tick(); } }); return meter; }