Load data into asynchronous datagrid

I load some data (1200000 rows) into a datagrid and the application takes too much time to load and sometimes freezes.

I don’t know how to load them asynchronously? (possibly with progressBar).

Can I find any help here?

+5
source share
2 answers

I have an application in which I am doing something very similar with Threading. This code should update your data one line at a time while the code is running.

using System.Windows.Threading;

private void Run()
{
    try
    {
        var t = new Thread(Read) { IsBackground = true };
        t.Start();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

private void Read()
{
    foreach (/* whatever you are looping through */)
    {
        /* I recommend creating a class for the result use that for the 
           datagrid filling. */
        var sr = new ResultClass()

        /* do all you code to generate your results */

        Dispatcher.BeginInvoke(DispatcherPriority.Normal, 
                               (ThreadStart)(() => dgResults.AddItem(sr)));   
    }    
}
+5
source

, , 100 1000 . WPF , ( INotifyCollectionChanged), WPF , .

, , ( 1,2 ). "chunking" .

SO, : ListView ?

+3

All Articles