Where to create singleton instance if I don't need this instance in my program?

Assume I have some singleton that just need to be instantiated. In constructor it starts timer, and updates some model data each second.

To execute singleton constructor I just need to reference it. I don't need resulting instance because I don't need to do anything with singleton it should exist during entire application execution.

However c# doesn't allow such construct: WcfLoader.Instance;

So I have to use this WcfLoader loader = WcfLoader.Instance; but i never use loader instance.

It looks odd, does it mean that I do something wrong?

Answers


Add a static Init method to your class, then call WcfLoader.Init instead of getting an instance. It won't look weird at all.


Need Your Help

How can I visualize GitHub branch history on Windows?

windows git version-control github github-for-windows

Every time I was thinking of switching all of our little team's projects to git / github, what pained me was that there didn't seem to be a tool to visualize all this social coding goodness.

How do you get jconsole charts to show decimals?

java jmx jconsole

If you return a double or float from your MBean jconsole seems to round it down to the nearest integer.