How to initialize a C# static class before it is actually needed?

后端 未结 5 1419
北海茫月
北海茫月 2021-02-05 10:54

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

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 11:13

    The approach doesn't seem icky to me. I might name the method Touch(), give it an empty body, and add an appropriate comment. Would that be sufficient to get you over your feeling that something doesn't feel right about this?

提交回复
热议问题