我如何打开其他线程来计算插入sql server表的记录数量?

时间:2015-05-26 09:09:48

标签: c# multithreading

我正在用c#创建一个Windows应用程序。我试图从csv文件中读取数据并将其数据插入到MS SQL服务器数据库表中。
我编写了这段代码来读取csv文件中的数据:

int counter=0;
System.IO.StreamReader objReader = new System.IO.StreamReader(openFileDialog1.FileName, Encoding.GetEncoding(1256));
do
{
    //this part read data line by line and insert into the sql server database
    counter++;//counter show line read
    //show counter value into the label

}


当我运行此代码时,标签挂起并且不显示任何内容。我认为应该打开一个新线程来在标签中显示一个计数器变量。如何创建新线程?

0 个答案:

没有答案