A very universal method is offered by my article:
Wish You Were Here… Only Once[
^].
The usage is unusually simple and looks like this:
if (FirstTime.Here)
ThisWillHappenButOnlyOnce();
where
FirstTime.Here
is the static method of my class and
ThisWillHappenButOnlyOnce
is your method (or anything, some block) you want to call only once per you runtime.
Warning! Implementation of this feature has good performance, very reliable and universal but… understanding of how it works can be a mind-bending. :-)
Please try.
You can use my library in any type of .NET project written in any language.
—SA