I am working with windows forms. I am using System.Timers.Timer
. Although I stopped the timer with timer.Stop()
, It still goes little bit more. I put some bool variable to prevent this but no luck. Anybody knows anyhting about it ?
Thank you.
timer = new System.Timers.Timer();
timer.Elapsed += OnTimedEvent;
timer.Interval = 1000;
timer.start();
public void cancelConnectingSituation(Boolean result)
{
connecting = false;
timer.Stop();
if (result)
{
amountLabel.Text = "Connected";
}
else
{
amountLabel.Text = "Connection fail";
}
}
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
if (device.position == 2 && connecting)
{
refreshTime();
setConnectingText();
}
else if (connecting)
{
setConnectingText();
}
else
{
refreshTimeAndAmount();
}
}