In a winform I want to display database records using datagrid, with
dataset for a couple of thousands records it seems very slow. I have
read an article in group microsoft.public.dotnet.languages.vb. It uses
datareader to solve this problem, it's a good idea. I have translated
it in c# and want to run this in a separate thread, but it does not
work, i have a blank datagrid.
Anyone can help me? Thanks a lot.
My source code is following:
static private System.Threading.Thread m_pThread = null;
public void FillDataGrid()
{
DataTable dtList = dbman.GetOrderListSchema();
dataGrid_orderlist.DataSource = dtList;
SqlDataReader reader = dbman.GetOrderListPro();
while( reader.Read() )
{
DataRow dr = dtList.NewRow();
object[] tmp = new object[dtList.Columns.Count-1];
reader.GetValues(tmp);
dr.ItemArray = tmp;
dtList.Rows.Add(dr);
dataGrid_orderlist.Refresh();
}
reader.Close();
}
private void FormSearch_Load(object sender, System.EventArgs e)
{
m_pThread = new System.Threading.Thread(new
System.Threading.ThreadStart(FillDataGrid));
m_pThread.Name = "FillDataGrid";
m_pThread.IsBackground = true;
m_pThread.Start();
}