The timer works fine if it's coded inside a button_click event handler, but it doesn't work if it is inside a method
<p>I found timer code from a web site and used it in my application and it works fine if I use the timer code inside a button_click handler, but I need to use the timer when I call a method, so I did copy and paste the same code from the button_click into the method but the timer always gives me zero. How do I fix it?</p>

<p>The following is the timer code.</p>

<pre><code>public partial class Form1 : Form
{
    //Timer decleration
    DateTime startTime, StopTime;
    TimeSpan stoppedTime;
    bool reset;

    bool startVariabl = true;
    // The rest of the code..

    private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
        if (startVariable) startMethod();
        //
        //The rest of the code...
    }

    private void startMethod()
    {
        //Timer
        tmDisplay.Enabled = true;

        // Reset display to zero
        reset = true;
        lblElapsed.Text = "00:00.00.0";

        // Start timer and get starting time
        if (reset)
        {
            reset = false;
            startTime = DateTime.Now;
            stoppedTime = new TimeSpan(0);
        }
        else
        {
            stoppedTime += DateTime.Now - StopTime;
        }
    }

    private void tmDisplay_Tick(object sender, EventArgs e)
    {
        DateTime currentTime;

        //Determine Ellapsed Time
        currentTime = DateTime.Now;

        // Display Time
        lblElapsed.Text = HMS(currentTime - startTime - stoppedTime);
    }

    private string HMS(TimeSpan tms)
    {
        //Format time as string; leaving off last six decimal places.
        string s = tms.ToString();
        return (s.Substring(0, s.Length - 6));
    }
</code></pre>

<p>I am new C# learner.</p>
