title: How to initialize a C# static class before it is actually needed?
body: <p>I have a static class with a static constructor that takes some time (10-15 seconds) to execute and fully initialize the class. In order to improve performance, I've decided to enable this static class to be explicitly initialized instead of when it is first needed so that it is ready to go when it actually needs to be used.</p>
  
  <p>My first thought was to create an <code>Initialize()</code> method for the class, but since I already have a static constructor, this method doesn't seem to need to do anything other than be the method to call to explicitly initialize the class without accessing any of its other public methods or properties. Having a method that does nothing directly doesn't seem right to me.</p>
  
  <p>Then I thought I can just move the code from the static constructor into this <code>Initialize()</code> method, but I'd also like the class to be initialized when it is first needed and the <code>Initialize()</code> method wasn't explicitly called.</p>
  
  <p>To summarize, I want the following criteria to be observed:</p>
  
  <ul>
  <li>I want to allow the static class to be explicitly initialized (likely by using a public <code>Initialize()</code> method).</li>
  <li>I don't want to have to access any other public methods or properties on the class when I don't need them, even though this would initialize the static class.</li>
  <li>If the class has not been explicitly initialized, I still want to initialize it when it is first needed (i.e. when accessing other public methods or properties with the intent of using the functionality or data they provide).</li>
  <li>This is a helper class and using the Singleton design pattern is not necessary for my purposes.</li>
  </ul>
  
  <p>What would be the proper way to observe the above criteria for a static class written in C#? This can also apply to other programming languages (e.g. Java), but I'm personally interested in a solution written in C#.</p>