Loading icons in two different sizes I am loading 3000 individual icons at run time one of my controls uses large icons, the other uses small icons. This works however seems terribly inefficient. The only way I can get the icons to be available in the small/large size is to have multiple image lists and have to load the file twice into each list.

 public partial class Form1 : Form
{

    ImageList imageListSmall = new ImageList();
    ImageList imageListLarge = new ImageList();
    BackgroundWorker IconLoaderBGWorker = new BackgroundWorker();
    DirectoryInfo IconDir = new DirectoryInfo("icons");

    FileInfo[] IconFiles;

    public Form1()
    {

        InitializeComponent();

        // Setup Icon Lists
        imageListSmall.ImageSize = new Size(16, 16);
        imageListSmall.ColorDepth = ColorDepth.Depth32Bit;
        imageListLarge.ImageSize = new Size(32, 32);
        imageListLarge.ColorDepth = ColorDepth.Depth32Bit;

        // Setup Progress bar events and Icon Loader
        IconLoaderBGWorker.DoWork += new DoWorkEventHandler(bg_DoWork);
        IconLoaderBGWorker.WorkerReportsProgress = true;
        IconLoaderBGWorker.ProgressChanged += new ProgressChangedEventHandler(bg_ProgressChanged);
        IconLoaderBGWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);

        IconFiles = IconDir.GetFiles("*.png");
        int allFiles = IconFiles.Count();
        progressBar1.Maximum = allFiles;

    }

    private void bg_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        progressBar1.Value = e.ProgressPercentage;
    }

    private void bg_DoWork(object sender, DoWorkEventArgs e)
    {
        int i = 0;

        foreach (FileInfo fileinfo in IconFiles)
        {
            imageListLarge.Images.Add(Path.GetFileNameWithoutExtension(fileinfo.Name), Image.FromFile(fileinfo.FullName));
            imageListSmall.Images.Add(Path.GetFileNameWithoutExtension(fileinfo.Name), Image.FromFile(fileinfo.FullName));
            IconLoaderBGWorker.ReportProgress(++i);
            Application.DoEvents();
        }

    }

    private void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        object result = e.Result;
        progressBar1.Dispose();
    }
}
I guess I was able to figure it out, not sure how I missed it but by simply adjusting the bg_DoWork the application loads twice as fast, as it only creates an Image once instead of twice.

    private void bg_DoWork(object sender, DoWorkEventArgs e)
    {
        int i = 0;
        Image tempImage;
        foreach (FileInfo fileinfo in IconFiles)
        {
            tempImage = Image.FromFile(fileinfo.FullName);
            imageListLarge.Images.Add(Path.GetFileNameWithoutExtension(fileinfo.Name), tempImage);
            imageListSmall.Images.Add(Path.GetFileNameWithoutExtension(fileinfo.Name), tempImage);
            IconLoaderBGWorker.ReportProgress(++i);
            Application.DoEvents();
        }
    }