Click here to Skip to main content
15,883,125 members

Comments by Sonhospa (Top 54 by date)

Sonhospa 27-Aug-23 16:44pm View    
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!
Sonhospa 26-Aug-23 12:02pm View    
Because I've been a member here, the post is from early 2019 and in C#. But your kind of help is of course inspiringly rude. Thank you for letting me learn.
Sonhospa 6-Aug-23 3:49am View    
I just had a brief look at your extension method and it seems quite complicated. As mentioned, I had managed to change your first suggestion to "stepwise UI reporting" with a simple loop from a Microsoft example (cool that the HTML works in this window, too):
Private Async Function RunTest() As Task

        Dim files As List(Of String) = Directory.GetFiles(Environment.CurrentDirectory).ToList()
        Dim Infos = files.Select(Function(file) New FileInfo(file))

        Dim tasks = Infos.Select(Function(fileInfo) ProcessFileAsync(fileInfo)).ToList

        While tasks.Count > 0
            Dim finishedTask As Task(Of FileInfo) = Await Task.WhenAny(tasks)
            ' ***Remove the selected task from the list so that you don't process it more than once.  
            ' ***Await the first completed task and display the results.  
            Dim result = Await finishedTask
            Console.WriteLine($"{vbCrLf}Result:  {result}{vbCrLf}")
            Console.WriteLine($"> {finishedTask.Result.Name} ist fertig!")
        End While

        Dim results = Await Task.WhenAll(tasks)
        Console.WriteLine($"> Alle Tasks sind fertig!")

    End Function
Or do you see anything 'odd' in that approach? Gotta mention that speed is critical so that the change to .NET Core may help more than anything else.
Sonhospa 6-Aug-23 3:40am View    
Wow, Graeme - thank you! I'm in the process of moving to .NET Core (here in Germany that's a bit more difficult coz I have to upgrade Win7 to Win10 first), so right now I can only thank you without even trying to digest your challenge... it's a lot of stuff you're using that I've not even tried to understand before (e.g. ".Getawaiter.Getresult" or "Predicate of") and which will surely require a few days. Have a good rest of the weekend!
Sonhospa 5-Aug-23 9:34am View    
Thank you ever so much – what a pity that 5 stars is max and I hope you don't mind ;-)

As mentioned I'm happy with your initial "wrap the linq" solution, but higly appreciate your additional suggestions, hoping I can recall them once needed (eventually, as I'm not a pro)! Meanwhile I've (successfully) played around with your 'RunTest' example, changed it to reporting each finished task (incrementally reducing the list of tasks) plus giving a final message once all are completed. Looks good and is fun ;-)

I hope you're having a good movie time with your wife!
Kind regards from rainy Munich (I'm currently in Germany).