PSThreadJob icon indicating copy to clipboard operation
PSThreadJob copied to clipboard

NONISSUE QUESTION... Variable Share/Scopes/Etc

Open AaronG1234 opened this issue 5 years ago • 1 comments

understandable in start-job global variables are not passed to the child because a whole new host is created. but in start-threadjob i was wondering/hoping there was a way to have a variable shared amongst parent and child and child and peers. Would it somehow be possible to pass a reference/pointer/etc. into the child.

btw.. I ran some test to see how far the Using: scope can be pushed, but it seems to be designed to eliminate the need to pass things into the scriptblock via a param() and argumentlist... they still seem to operate at a Local: scope

I do realize that there is also value in keeping maximum parity with start-job... but because the thread is still in the same host exe... i was wondering if it was possible, reasonable, and desirable (for others)

AaronG1234 avatar Dec 10 '19 00:12 AaronG1234

I should note the tests I have done with Global involve a web-session from Invoke-WebRequest... even global it seemed to serialize across parent child unless i passed as argument (or Using:) however when the session adjusted (say added a cookie) at the parent it was not reflected at the children.

So.. maybe global: does work in some circumstances...

AaronG1234 avatar Dec 10 '19 00:12 AaronG1234