ÇáãÓÇÚÏ ÇáÔÎÕí ÇáÑÞãí

ãÔÇåÏÉ ÇáäÓÎÉ ßÇãáÉ : Force static objects to load when program starts, not lazy (load when first used)?



C# Programming
03-09-2010, 03:00 AM
I have a base class that has

private static List _items = new List();
public MyClass()
{
...
_items.add(this);
...
}
This class is used by plug-ins to add some data to the “global list”. My program does a search for items in the “global list” but any instance of MyClass that hasn’t been used yet doesn’t appear in the list (lazy creation). I am thinking about adding a dummy public void Run() { } method to the class, then have my program search all plug-ins and tell them to execute Run(); but it seems like there should be a better way.

Does anyone know of a better method or a “best-practice” way of doing this?

Thank you all in advance!