I am using wpf DispatcherTimer and I want ot use it into the for loop how i can use it..
my code is here..
DispatcherTimer timer = new DispatcherTimer();
timer.Tick += (s, e) =>
{
for (i = 0; i < 10; i++)
{
obsValue.Add(new Entities(i));
timer.Interval = TimeSpan.FromSeconds(30);
timer.Start();
}
};
Thanks….
When you start a timer with
Intervalset to30 seconds, itsTickevent will be raised every 30 seconds.Now, what I understand from your question is you want to add a record every 30 seconds.
Here is what you can do. Note that it does not require a
for loopbut you still need to maintain current index. To do that, you can use aprivate fieldor alocal variable with lambda.Example: