Forum Discussion

Rober2024's avatar
Rober2024
Copper Contributor
Jul 31, 2024

do-while in parallel

Good morning:
I have a code in C# Framework 4.8 that has a rather heavy do-while. I would like to know if there is a way to run it in parallel like for or foreach, which have their parallel versions.
Thanks

2 Replies

  • Mousefluff's avatar
    Mousefluff
    Iron Contributor

    Rober2024  Even in PowerShell, as with C#, Classes can be used alongside the default PowerShell Cmdlets, though you may have to create a new .NET object, or use Class Inheritance to get similar functionality:

    PowerShell - Creating .NET and COM objects -> https://learn.microsoft.com/en-us/powershell/scripting/samples/creating-.net-and-com-objects--new-object-?view=powershell-7.4
    PowerShell - Using static classes and methods -> https://learn.microsoft.com/en-us/powershell/scripting/samples/using-static-classes-and-methods?view=powershell-7.4
    PowerShell - Classes - Limitations -> https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes
    .NET API browser -> https://learn.microsoft.com/en-us/dotnet/api/
    System.Threading Namespace -> https://learn.microsoft.com/en-us/dotnet/api/system.threading?view=netframework-4.0
    System.ComponentModel Namespace -> https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel?view=netframework-4.0
  • Arabidopsis's avatar
    Arabidopsis
    Copper Contributor
    Parallel does not support do while, but you can use Parallel To achieve the exact same functionality, but with some complexity.

Resources