I got this timer (timer2) and it runs every 60 seconds..
And I got this second timer (timer4)
when 60 seconds are over, the timer2_Tick does a few things and initiates timer4.
timer 4 makes sure to wait 4 seconds before coming in action (I need 4 seconds to be sure that all the downloaded data is there)
when these 4 seconds are over the timer should change an image and it does..
So it all works..
The problem is that every 4 seconds the image blinks.. the image is inside an datta template..
how do I stop that..?? do i need the Stop() or do I need an running counter..??
please help this is driving me nuts..
private void timer2_Tick(object sender, EventArgs e )
{
locationTextBox2.Text = "";
if (locationTextBox2.Text == "")
{
Weatherframe.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("");
}
Weatherframe2.Source = Weatherframe.Source;
System.Windows.Threading.DispatcherTimer timer4 = new System.Windows.Threading.DispatcherTimer();
timer4.Interval = new TimeSpan(0, 0, 0, 4, 000); // 500 Milliseconds
timer4.Tick += new EventHandler(timer4_Tick);
timer4.Start();
}
void timer4_Tick(object sender, EventArgs e)
{
if (locationTextBox2.Text == String.Empty)
{
locationTextBox2.Text = textBlock2.Text;
}
}
You never stop the timer, so it will keep ticking every fourth second.
Just call
Stopon the timer in the handler, but for that you need to keep the reference to the timer in a member variable so that you can access it after you created it.