Click here to Skip to main content
16,017,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

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!
Michael

What I have tried:

The Extension method:
VB
<Extension>
 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
                                    increment.Invoke
                                End If
                                Return x
                            End Function)
 End Function
The call:
VB
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
Posted
Updated 28-Aug-23 9:34am
v2
Comments
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
 
Comments
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