PaulHigin / PSThreadJob

A PowerShell module for running concurrent jobs based on threads rather than processes
MIT License
180 stars 18 forks source link

NONISSUE QUESTION... Variable Share/Scopes/Etc #48

Open AaronG1234 opened 4 years ago

AaronG1234 commented 4 years ago

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 commented 4 years ago

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...