public Subscription(PerformanceCounterObservable observable, IObserver <PerformanceCounterSample> observer) { // create a new counter for this subscription _counter = observable._createCounter(); _pollingInterval = observable._pollingInterval; _observer = observer; // seed previous sample to support computation _previousSample = _counter.NextSample(); // create a timer to support polling counter at an interval _timer = new Timer(Sample); _timer.Change(_pollingInterval.Milliseconds, -1); }
public static CepStream <PerformanceCounterSample> CreateInput( Application application, string categoryName, string counterName, string instanceName, TimeSpan pollingInterval, string streamName = null) { IObservable <PerformanceCounterSample> source = new PerformanceCounterObservable(categoryName, counterName, instanceName, pollingInterval); AdvanceTimeSettings advanceTimeSettings = AdvanceTimeSettings.IncreasingStartTime; return(source.ToPointStream(application, s => PointEvent.CreateInsert(s.StartTime, s), advanceTimeSettings, streamName)); }