I am trying to keep updating my linechart according to the updated information in my application but it keeps returning the error InvalidOperationException.

The code works fine if I input static information. My codes as follows. Appreciate any help. Thanks. 

CPUEvent is firing off every second. CurrentCPU is the value of the cpu every second. This information is updated every second. 

```
List<KeyValuePair<double, double>> cpuList = new List<KeyValuePair<double, double>>(); 
public int counter = 0; 

public MainWindow()
        {
            InitializeComponent();
            CPUEvent += showChart; 
        }

private void showChart(object sender, CPUEventArgs args) //////
        {
            counter += 1;
            cpuList.Add(new KeyValuePair<double, double>(counter, args.CurrentCPU)); 
            lineChart.DataContext = cpuList;  
        }

```