System.OutOfMemoryException使用this.Dispatcher.BeginInvoke时wpf datagrid ObservableCollection

时间:2016-11-21 12:35:49

标签: c# wpf multithreading datagrid

此函数在一个线程中运行:

private void uReadBinaryDataset()
    {
        using (StreamReader sr = new StreamReader(m_sFileName))
        {
            using (BinaryReader br = new BinaryReader(sr.BaseStream))
            {
                long read = 0;
                long count = br.BaseStream.Length;
                while (read < count)
                {
                    long ticks = br.ReadInt64();
                    float fv1 = br.ReadSingle();
                    float fv2 = br.ReadSingle();
                    this.Dispatcher.BeginInvoke((Action)delegate
                    {
                        liDataSet.Add(new DataFormat(ticks, fv1, fv2));
                    });
                    read += sizeof(long) + 2 * sizeof(float);
                }
            }
        }
    }

liDataSet是一个ObservableCollection,uReadBinaryDataset是我的wpf窗口的成员 这给了这个例外

  

未处理的类型&#39; System.OutOfMemoryException&#39;发生在mscorlib.dll

0 个答案:

没有答案