使用SqlBulkCopy.writeToServer()方法将大量数据复制到数据时,UI处于无响应状态. [英] UI goes in not responding state while copying huge amount to data using SqlBulkCopy.writeToServer() method.

查看:796
本文介绍了使用SqlBulkCopy.writeToServer()方法将大量数据复制到数据时,UI处于无响应状态.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SqlBulkCopy类从MS访问SQL Server(从客户端到服务器)复制4500000条记录,该过程成功结束,但UI处于未响应状态,我使用了进度条来显示复制进度数据,它也停止增加...并且在处理结束时,突然显示100%的处理完成,并且数据成功处理.我应该怎么做才能使UI和进度栏处于活动状态?

i am using SqlBulkCopy Class to copy 4500000 records from MS access to SQL server(from client to server), the process ends successfully but the UI goes in not responding state, i have used a progress bar to show the progress of copying data, it also stops incresing...and at the end of process, suddenlly shows 100% copletion of process, and data coped successfully. what should i do to make UI and progress bar active?

推荐答案

您应该创建一个线程并在其中执行SqlBulkCopy,而不要在冻结的主线程中进行操作用户界面.
You should create a thread and do the SqlBulkCopy in there instead of doing it in the main thread which freezes the user interface.


这篇关于使用SqlBulkCopy.writeToServer()方法将大量数据复制到数据时,UI处于无响应状态.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆