Click here to Skip to main content
15,917,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I've been struggling for hours now with the proper syntax (in VB) to use an extension method for the above goal which I found here. Whilst the method that contains the call runs without throwing errors, the ProgressBar isn't updated and I can't even identify where the control would be called.

Would someone please be so kind as to correct my syntax?

Thank you!

What I have tried:

The Extension method:
 Public Function WithProgressReporting(Of T)(sequence As ParallelQuery(Of T), increment As Action) As ParallelQuery(Of T)

     Return sequence.Select(Function(x)
                                If increment IsNot Nothing Then
                                End If
                                Return x
                            End Function)
 End Function
The call:
Dim completed As Long = 0
     Dim queryMatchingFiles = From fi In filelist.AsParallel().WithProgressReporting(Function() Interlocked.Increment(completed))
                              Where FilterForLTO(fi) = True
                              Select fi

     Return queryMatchingFiles
Updated 28-Aug-23 9:34am
Richard MacCutchan 26-Aug-23 11:01am    
Why not ask the person on SO who wrote the code?

1 solution

Use the second answer on the page, not the first one.
Share this answer
Sonhospa 27-Aug-23 16:44pm    
Thank you, Dave, for exposing my "blind spot" to me. After conversion to VB (which I can just read better) it starts making much more sense now, and I'm confident to get it working as soon as I find the time. Have a good day!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900