I' try to create asynchronous call to load 2million data.I' just create a simple application to load 4 columns.but I just need on starting time it's load 1000 records.and show to the user after background it's load all the data after few seconds it's add the record another 1000 records.

  private void bindgrid()
    {

        dt.Columns.Add("Id", typeof(int));
        dt.Columns.Add("Name", typeof(String));
        dt.Columns.Add("Surname", typeof(String));
        dt.Rows.Add(1, "sourav", "kayal");
        dt.Rows.Add(2, "Ram", "Kumar");
        dt.Rows.Add(3, "Shyam", "Kymar");

    }
    public Task<DataTable> LoadData1()
    {
        return Task.Run(() =>
        {
            System.Threading.Thread.Sleep(10000);
            return dt;
        });
    }
    public Task<DataTable> LoadData2()
    {
        return Task.Run(() =>
        {
            System.Threading.Thread.Sleep(10000);
            return dt;
        });
    }


    protected async void btn_Click(object sender, EventArgs e)
    {
        gvdata.DataSource = await LoadData1();
        gvdata.DataBind();
        GridView1.DataSource = await LoadData2();
        GridView1.DataBind();
    }   

Related posts

Recent Viewed