Click here to Skip to main content
15,881,803 members
Articles / Programming Languages / C#

Implement an Autoplay Handler

Rate me:
Please Sign up or sign in to vote.
5.00/5 (22 votes)
18 Sep 2006CPOL8 min read 117.5K   1.7K   78  
Implementing an Autoplay handler in C#.
using System;
using System.Collections.Generic;
using System.Text;

/***************************************************************************
 * The code in this class was originally developed by Marc Clifton in
 * the article: http://www.codeproject.com/csharp/idispose.asp.  All
 * I can take credit for is implementing it as a  class that can be used as 
 * a base class to encapsulate the Disposable Implementation
 ***************************************************************************/
namespace Almdal.SharedPipes {
	public class IDisposableImpl : IDisposable {
		private bool _disposed = false;
		#region Destructor
		~IDisposableImpl() {
			Dispose(false);
		}
		#endregion

		#region IDisposable Members
		public void Dispose() {
			Dispose(true);

			GC.SuppressFinalize(this);
		}
		#endregion

		protected void Dispose(bool disposeManagedResources) {
			// process only if mananged and unmanaged resources have
			// not been disposed of.
			if (!_disposed) {
				if (disposeManagedResources) {
					// dispose managed resources
					DisposeManagedResources();
				}
				// dispose unmanaged resources
				DisposeUnmanagedResources();
				_disposed = true;
			}
		}

		protected virtual void DisposeUnmanagedResources() { }

		protected virtual void DisposeManagedResources() { }
	}
}

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)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions