title: Singleton with parameters
body: <p>I need a singleton class to be instantiated with some arguments. The way I'm doing it now is:</p>
  
  <pre><code>class SingletonExample
  {
       private SingletonExample mInstance;
       //other members... 
       private SingletonExample()
       {
  
       } 
       public SingletonExample Instance
       {
           get
           {
                if (mInstance == null)
                {
                    throw new Exception("Object not created");
                }
                return mInstance;
           }
       }
  
       public void Create(string arg1, string arg2)
       {
           mInstance = new SingletonExample();
           mInstance.Arg1 = arg1;
           mInstance.ObjectCaller = new ObjectCaller(arg2);
           //etc... basically, create object...
       } 
  }
  </code></pre>
  
  <p>The instance is created 'late', meaning I don't have all of the needed arguments on app startup.</p>
  
  <p>In general I don't like forcing an ordering of method calls, but I don't see another way here. The IoC wouldn't resolve it either, since where I can register it in the container, I can also call Create()... </p>
  
  <p>Do you consider this an OK scenario? Do you have some other idea? </p>
  
  <p><strong>edit</strong>: I <em>know</em> that what I wrote as an example it's not thread safe, thread-safe isn't part of the question</p>