日期:2014-05-17  浏览次数:20704 次

求优化利用异步线程生成shp文件时,速度比没加线程慢了三倍。
求优化在生成shp文件时,由于数据有点多,程序界面会出现卡死的假象,实际上程序还是处在运行状态。为了知道程序运行到哪里并解决假死的现象,我添加了一个异步进度条后能够知道程序正在处理哪一行数据,但是处理效率实在是太慢了。求大家支招优化:有没有什么方法能知道程序运行进度,并解决假死现象
 #region 创建文件窗体
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Shape文件(*.shp)|*.shp";
                saveFileDialog.Title = "新建点形shp文件";
                saveFileDialog.CheckFileExists = false;
                DialogResult dialogResult = saveFileDialog.ShowDialog();

                IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
                int index;
                string fileName;
                //string filePath; 
                string fileFullPath;
                if (dialogResult == DialogResult.OK)
                {
                    fileFullPath = saveFileDialog.FileName;
                    index = fileFullPath.LastIndexOf(@"\");
                    fileName = fileFullPath.Substring(index + 1);
                    filePath = fileFullPath.Substring(0, index);
                    if (System.IO.File.Exists(saveFileDialog.FileName))//检查文件是否存在
                    {
                        if (MessageBox.Show("该文件夹下已经有同名文件,替换原文件?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            IFeatureWorkspace FWS = pWorkspaceFactory.OpenFromFile(filePath, 0) as IFeatureWorkspace;