Handling IDisposable Objects in a Generic List

I wanted to have more precise control over the lifetime of objects I was keeping in a list rather than wait for the GC. I came up with the code below which adds a few extension methods for handling IDisposable objects in a generic list. This was more elegant than adding a helper class.

I only implemented what I needed for the current project but these are very straightforward to do.

Sample code below.

using System;
using System.Collections.Generic;

namespace MyExtensions
    public static class Extensions
        /// Remove tail, starting at index.
        public static void RemoveTail<T>(this List<T> list, int index)
            if (index >= list.Count) { return; }

            if (typeof(IDisposable).IsAssignableFrom(typeof(T)))
                List<T> temp = list.GetRange(index, list.Count - index);
            list.RemoveRange(index, list.Count - index);
        public static void ClearAndDispose<T>(this List<T> list)
            if (typeof(IDisposable).IsAssignableFrom(typeof(T)))
                foreach (T obj in list)
                    IDisposable iFace = (IDisposable)obj;
    } //*** Extensions
} //*** namespace

Usage is simple.

using MyExtensions;

var myList = new List<HugeObject>();



Escher Version 0.2

Escher Version 0.2 is up.

This version fixes the flicker issue, adds undo, fill/no-fill enclosed shapes, and drawing crosshairs.

Escher is a free, fun multi-shape drawing program for doodling, like a cross between MSPaint and a kaleidoscope.

More details here:  http://www.georgepotts.com/apps/escher/


SSELibrary 0.2 Available

SSELibrary 0.2 available for download. This version includes a much larger library of functions (149) with nearly full coverage of 8-bit operations, as well as enhanced CPU feature detection.

Details here: http://www.georgepotts.com/apps/sse-library/

Vibratium 1.0.2 Update

Vibratium Version 1.0.2 is now available. I fixed a few bugs and added a new Diff combine option.


Introducing Vibratium


Download Vibratium 1.0.1
Download Vibratium 1.3
(More info here http://www.georgepotts.com/apps/vibratium/)

Vibratium allows you to generate unique animations that would be impossible to do manually.  This is done by combining the output of “render points,” which are wave-based animations, each centered at a single point.

Click the images above to view the 800×800 versions in new tabs.  I especially like the red one as I somehow generated a triangle fractal pattern. (Note that it links to the bmp version which is ~2.4MB.)


Videos here – YouTube Vibratium Playlist
Here’s the project file for the first video – BlackAndBlueWaves.zip

Continue reading