我有以下代碼:Parallel.ForEach與ListView的
Parallel.ForEach(this.listView2.CheckedItems,
new ParallelOptions { MaxDegreeOfParallelism = 4 },
(CheckedItem) =>
{
//do something
});
,我得到以下編譯錯誤:
The type arguments for method 'System.Threading.Tasks.Parallel.ForEach(System.Collections.Concurrent.OrderablePartitioner, System.Threading.Tasks.ParallelOptions, System.Action)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
我搜索有關如何使用列表視圖與任務,但couldn」找不到任何東西。
如何在ListView中使用Parallel.ForEach?
這是編譯? –
不,我得到那個錯誤 –
正確的理由是因爲CheckedItems集合就是這樣一個集合,所以它不能「推斷」這個類型。集合的基本類型是什麼? –