How do I make timer2 run the function only once if the process is running?
<p>In this function I'm checking if the game us running or not.</p>

<p>If it's running I'm starting the <code>backgroundworker</code>.</p>

<p>Then in <code>timer2</code> I keep checking if the process is running until I will quit the game.</p>

<p>But I don't want it to keep checking if it's running or not and start the <code>backgroundworker</code> all over again and again...</p>

<p>So in one side I want that <code>timer2</code> will run the function all the time until I quit the game in the other hand I don't want it to start the <code>backgroundworker</code> all the time.</p>

<pre><code>private void wichProcessIsrun()
{
    Process[] pname = Process.GetProcessesByName("BFBC2Game");
    if (pname.Length == 0)
    {
        Logger.Write("Battlefield Bad Company 2 Ended");
    }
    else
    {
        Logger.Write("Battlefield Bad Company 2 Started");
        backgroundWorker1.RunWorkerAsync();
    }
}

private void timer2_Tick(object sender, EventArgs e)
{
    wichProcessIsrun();
}
</code></pre>
