proxb / PoshRSJob

Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.
MIT License
541 stars 87 forks source link

Shared dynamic variables in pre-execution function #167

Closed tyteen4a03 closed 6 years ago

tyteen4a03 commented 6 years ago

I'm setting up a mini-framework for a general task runner in which the tasks can define shared variables in a pre-execution function (Setup); the variables defined within will be available to all tasks invoked by Start-RSJob. I have no control over what variables will be set up in the Setup function, but all of them will need to be available in the jobs.

(If it helps, the variables will be read-only.)

What's the best way to do this with RS Jobs?

MVKozlov commented 6 years ago

I think it is Synchronized hash you can search for examples at Boe's website (or inside module :)

tyteen4a03 commented 6 years ago

I ended up creating a $globals variable and stuffing everything I need into the variable. I was looking for something that's closer to $Using but my solution works well for me.