Tag: parallel.foreach

每次读取Excel工作表时使用并行foreach的不同结果

Imports System.IO Imports System.Threading Imports System.Threading.Tasks Imports System.Collections.Concurrent Imports Excel = Microsoft.Office.Interop.Excel Public Class TestCarDatas Public Property RowID As Integer Public Property ModelYear As Integer Public Property VehMfcName As String Public Property EmgVeh As Boolean End Class Module ExcelParallelDataGather2 Public Const ExcelVehDataPath As String = "D:\Users\Dell\Desktop" Public rwl As New System.Threading.ReaderWriterLock() Public rwl_writes As Integer […]

我如何使用Parallel.ForEach for Excel?

我正在尝试使用Parallel.ForEach for Excel,但我得到错误。 代码是 using System.Threading.Tasks; using Excel = Microsoft.Office.Interop.Excel; public void function(Excel.Range range) { Parallel.ForEach(range, item=> { //do stuff }); } 错误是错误7:方法'System.Threading.Tasks.Parallel.ForEach(System.Collections.Generic.IEnumerable,System.Action)'的types参数不能从用法推断。 尝试明确指定types参数。 如果您有任何想法,我将非常感激。