Runspaces - Lets Work in Parallel

Поделиться
HTML-код
  • Опубликовано: 29 дек 2024
  • НаукаНаука

Комментарии • 1

  • @stereoactivo
    @stereoactivo 8 месяцев назад

    Hi! thanks for this, it was super useful.
    I was following this to achieve the same result, however I'm having some issues with it, maybe you can give me a hand.
    Instead of Start-Sleep -Seconds $sleep, I created a class:
    class MyBackgroundTask {
    [void] run() {
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    Write-Host "$Timestamp Starting background task..."
    Start-Sleep -Seconds 20
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    Write-Host "$Timestamp Background task completed."
    }
    }
    However, when calling run() on the object, all the parallelism is gone. Do you have any idea how to fix it?