I have a WPF application for plotting a chart dynamically a shown in the following code.
public ObservableCollection<KeyValuePair<int, double>> Items { get; set; }
public void startgraph
{
for (i = 0; i < 60; i++)
plot_values[i] = random.NextDouble() * 100;
bw = new BackgroundWorker();
bw.DoWork += (o, ea) =>
{
index = 1;
while (index < 60)
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
Items.Add(new KeyValuePair<int, double>(index++, plot_values[index]));
}));
System.Threading.Thread.Sleep(1000);
}
};
bw.RunWorkerAsync();
}
I want to have a pause button which when clicked pauses the plot and when clicked again resumes the plot. Please help.