How to run a method in a loop only once?
<p>I'm using a switch as a state manager for my XNA game. The switch is a part of main update method, so it's run every frame. Sometimes I need to set a timer value and it should only be set once per method call. There are multiple methods that set the timer per case, so it can't use the current and previous state numbers to check if it's ok to overwrite previous time.</p>

<pre><code>case "state 34": {
SetTime(theTime); // should run only once
// other things
if (TheTimeisRight(time)) // runs every call
    {
        SetTime(theTime); // should run only once
        if (TheTimeisRight(time)) 
        { /*  some methods  */ }
    }
break; }
</code></pre>

<p>How can I make this work, or is there a better way to do this without going outside the switch? (changing SetTime method is ok, but I wouldn't like to clutter up the switch with additional code)</p>
