1
我試圖將下面的代碼轉換爲並行循環。使用Parallel.ForEach代替ForEach的正確語法是什麼?將每個GridViewRow轉換爲Parallel.ForEach GridViewRow
For Each grow As GridViewRow In gvEmployees.Rows
SendSummaryReport(grow)
Next
我試圖將下面的代碼轉換爲並行循環。使用Parallel.ForEach代替ForEach的正確語法是什麼?將每個GridViewRow轉換爲Parallel.ForEach GridViewRow
For Each grow As GridViewRow In gvEmployees.Rows
SendSummaryReport(grow)
Next
這是我用得到它的工作:
Parallel.ForEach(Of GridViewRow)(gvEmployees.Rows.OfType(Of GridViewRow)(), (AddressOf SendSummaryReport))
你會想要做
Parallel.ForEach(Of GridViewRows)(gbEmployees.Row, Function(grow) SendSummaryReport(grow))
當我嘗試,我得到這個錯誤: 超載分辨率失敗,因爲沒有可訪問的'ForEach'可以用這些參數調用: '公共共享函數ForEach(Of TSource)(source As Sys tem.Collections.Concurrent.OrderablePartitioner(Of TSource),body As System.Action(Of TSource,System.Threading.Tasks.ParallelLoopState,Long))As System.Threading.Tasks.ParallelLoopResult':類型的數據類型參數不能從這些參數中推斷出來。明確指定數據類型可能會更正此錯誤。 ... – SchwartzE 2011-02-17 18:52:57