Click here to Skip to main content
15,896,557 members
Articles / Desktop Programming / WPF

Monitoring Process Statistics in C# WPF

Rate me:
Please Sign up or sign in to vote.
4.85/5 (24 votes)
25 Jul 2009CPOL3 min read 128K   7.8K   79  
In this article, I will explain the performance monitoring of any instance in the Form of statistics and graphs as well.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections;

namespace MemoryPerformanceMonitoring
{
	public sealed class FilteringDataSource<T> : IEnumerable<T>, INotifyCollectionChanged
	{
		private readonly IList<T> collection;

		public FilteringDataSource(IList<T> collection, IFilter<T> filter)
		{
			if (collection == null)
				throw new ArgumentNullException("collection");
			if (filter == null)
				throw new ArgumentNullException("filter");
	

			this.collection = collection;
			
			INotifyCollectionChanged observableCollection = collection as INotifyCollectionChanged;
			if (observableCollection != null)
			{
				observableCollection.CollectionChanged += collection_CollectionChanged;
			}

			this.filter = filter;
		}

		void collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
		{
			RaiseCollectionChanged();
		}

		private readonly IFilter<T> filter;

		public IEnumerator<T> GetEnumerator()
		{
			return ((IEnumerable<T>)filter.Filter(collection)).GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		private void RaiseCollectionChanged()
		{
			if (CollectionChanged != null)
			{
				CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
			}
		}
		public event NotifyCollectionChangedEventHandler CollectionChanged;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions