Skip to content

Instantly share code, notes, and snippets.

@kerslake
Created October 2, 2014 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerslake/2470ac76678747f77786 to your computer and use it in GitHub Desktop.
Save kerslake/2470ac76678747f77786 to your computer and use it in GitHub Desktop.
void Main()
{
IObservable<PerformanceSample> performanceCounterObservable = PerfCounterObservable.FromRealTime(TimeSpan.FromSeconds(1), new[]{
@"\Processor(_Total)\% Processor Time",
@"\Memory(_Total)\% Committed Bytes In Use",
@"\Memory(_Total)\Available MBytes"})
.Take(6);
performanceCounterObservable.Subscribe(new PerfSampleObserver());
}
class PerfSampleObserver : IObserver<PerformanceSample>
{
public void OnNext(PerformanceSample sample)
{
sample.Dump();
}
public void OnError(Exception error)
{
}
public void OnCompleted()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment