0

这是我的代码:

            int ThreadCount = FilteredViewTable.Count;
            int chunksize = ThreadCount + 1;
            int lastbatch = 0;
            int batchCount = 0;
            if (ThreadCount > chunksize)
            {
                batchCount = ThreadCount / chunksize;
                lastbatch = ThreadCount % chunksize;
            }
            else
                lastbatch = ThreadCount;

            if (lastbatch > 0)
                batchCount++;

            int endThread = 0;
            int counter = 0;
            while (counter < batchCount)
            {
                int StartPos = counter == 0 ? 0 : (endThread * counter);
                counter++;

                if (counter == batchCount && lastbatch != 0)
                    endThread = lastbatch;
                else
                    endThread = chunksize;

                int EndPos = endThread;

                ObservableCollection<ManualSendingData> dtTempFilteredData = new ObservableCollection<ManualSendingData>();
                mnThreadCount = 1;
                Int32 lnRowCount = 0;
                Decimal RowsPerThread = 0;
                Array.Resize(ref moProcessFilesThreads, mnThreadCount);

                Array.Resize(ref moDataTables, mnThreadCount);
                Array.Resize(ref moEmailThreadsErrors, mnThreadCount);
                Array.Resize(ref mcThreadsErrors, mnThreadCount);
                Array.Resize(ref mnMailCount, mnThreadCount);

                RowsPerThread = Math.Round(Convert.ToDecimal(endThread / GlobalStatic.gcThreads), 0);
                List<ManualSendingData> lo = FilteredViewTable.Skip(StartPos).Take(endThread).ToList();


                foreach (ManualSendingData drRow in lo)
                {
                    lnRowCount += 1;
                    moMainDataTable.Where(item => item.ClientCode == drRow.ClientCode).ToList().ForEach((DataItem) =>
                    {
                        dtTempFilteredData.Add(DataItem);
                    });
                    if (lnRowCount == RowsPerThread)
                    {
                        Array.Resize(ref moProcessFilesThreads, mnThreadCount);
                        Array.Resize(ref moDataTables, mnThreadCount);
                        Array.Resize(ref moEmailThreadsErrors, mnThreadCount);
                        Array.Resize(ref mcThreadsErrors, mnThreadCount);
                        Array.Resize(ref mnMailCount, mnThreadCount);
                        moDataTables[mnThreadCount - 1] = new ObservableCollection<ManualSendingData>();
                        moDataTables[mnThreadCount - 1] = new ObservableCollection<ManualSendingData>(dtTempFilteredData);
                        mnMailCount[mnThreadCount - 1] = Convert.ToInt32(dtTempFilteredData.Count);
                        moProcessFilesThreads[mnThreadCount - 1] = new Thread(new ParameterizedThreadStart(ProcessFiles));
                        moProcessFilesThreads[mnThreadCount - 1].Name = (mnThreadCount - 1).ToString();
                        moProcessFilesThreads[mnThreadCount - 1].Start((object)dtTempFilteredData);
                        lnRowCount = 0;
                        mnThreadCount += 1;
                        dtTempFilteredData = new ObservableCollection<ManualSendingData>();
                    }
                }
                List<int> CompletedThreads = new List<int>();
                int inTableCount = 0;
                int inRowCount = 0;

            }

在这里,我正在“ProcessFiles”方法中执行签名过程

以前我使用“.pfx”文件在 30 分钟内签署 PDF/HTML文件。现在我被迫使用位于电子令牌(连接到 USB 端口)上的证书,然后相同的过程大约需要。6个小时。

我正在开发WPF/C#应用程序

对于 HTML 签名,我使用了 Chilkat。对于 PDF 签名,我使用了 Itextsharp

有什么建议可以加快这个过程吗?

4

0 回答 0