[英]Parallel.ForEach is not executing the method
我正在嘗試並行化以下For Each循環,它按預期工作。 我從這開始:
foreach (DataRow drGroup in dsGroups.Tables["Table"].Rows)
ProduceInvoices(drGroup);
並將其更改為:
Parallel.ForEach<DataRow>((IEnumerable<DataRow>)dsGroups.Tables["Table"].Rows, ProduceInvoices)
但是,盡管dsGroup包含行,但ProduceInvoices
似乎不再執行。
請你能給我指點和/或在哪里看?
嘗試使用AsEnumerable
方法:
Parallel.ForEach<DataRow>(dsGroups.Tables["Table"].AsEnumerable(), ProduceInvoices);
Rows
屬性返回DataRowCollection
,它不實現IEnumerable<T>
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.