Message 1 of 6
Parallel Loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I would like to change my source code from "For Each" to "Parallel.Foreach" as to increase processing by using Threads!
Each time, I've failed in changing this code and my net searching were unsucceeded!
Here's my source with "For Each" loop:
Using acTrans = acCurDb.TransactionManager.StartTransaction()
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForRead)
For Each acObjId As ObjectId In acBlkTblRec
Dim MyEnt As Entity = acTrans.GetObject(acObjId, OpenMode.ForRead)
If MyEnt.Layer = LayerVal Then
'Nombre d'objets dans le calque séléctionné'
iMax += 1
'Nombre d'objets à traiter dans le calque séléctionné'
Select Case acObjId.ObjectClass.DxfName
Case "ARC", "CIRCLE", "LINE", "LWPOLYLINE", "POINT", "REGION"
iUtil += 1
End Select
End If
Next acObjId
End UsingI know that "Parallel.Foreach" deal with "IEnumerable Class" but i'm really lost!
Any idea!?