In my program I import millions of records to a SQL Server database with the help of SqlBulkCopy class. Since this is a heavy lifting it takes quite some time. While the process goes on I want to show the progress in a progressbar control. To be notified for the rows copied I’ve done this:
.......
bulkCopy.NotifyAfter = 2000;
bulkCopy.SqlRowsCopied += new SqlRowsCopiedEventHandler(bulkCopy_SqlRowsCopied);
.......
Now in the bulkCopy_SqlRowsCopied method I want to change the value of the progress bar. But I think I need to make it on a seperate thread. How can I do this?
You can have one extension class, like
Now when ever and where ever you want to update status of progress bar, you can do
Hope this works for you.