RamblingCookieMonster / Invoke-Parallel

Speed up PowerShell with simplified multithreading
MIT License
384 stars 88 forks source link

How do run without needing input objects? #28

Closed artisticcheese closed 7 years ago

artisticcheese commented 8 years ago

I'm trying to hit a website untill I want to stop with 50 threads with various URLs. Right now I have to do 1..1000000 | Invoke-Parallel {} which I assume creates some enormous hashtable, enumerates it etc with none of those things needed. I understand it's needed obviously for progress bar etc but I'd rather have something like below or what is the best way to accomlish it?

while ($true) {Invoke-Parallel}

RamblingCookieMonster commented 8 years ago

Hi!

Your approach seems about right. An alternative would be to write a script / function around that use case, rather than trying to shoe-horn Invoke-Parallel.

The main issue is that Invoke-Parallel expects you to pass it an input object - even if you pipe these in, it won't start doing anything until it has the full array of items lined up and ready to go.

You might consider @proxb's PoshRSJob - your scenario seems like it could fit into the idea of RSJobs, and you wouldn't need to worry about writing your own runspace handling.

Cheers!