Invoke-Parallel icon indicating copy to clipboard operation
Invoke-Parallel copied to clipboard

Using a shared & synchronized variable to hold a counter

Open banyula opened this issue 7 years ago • 2 comments

I need to display the number of records being processed by Invoke-Parallel in a WinForms variable. For that I need to keep a Counter variable. I tried Boe's synchronized hash table however it did not work, numbers were erratic and counter was wrong. I am able although to display an online array list of the records being processed, however the count is needed for displaying a progress bar using WinForms.

I assume this is an old request, so I wonder if you can throw a sample script to show how to achieve it.

banyula avatar Sep 28 '18 00:09 banyula

Fyi I've had success with this using PSframework. There are runspaxe functions to allow working with an object in a thread safe manner. Putting note here in case it helps someone else who sees this.

sheldonhull avatar Jul 13 '19 02:07 sheldonhull

Fyi I've had success with this using PSframework. There are runspaxe functions to allow working with an object in a thread safe manner. Putting note here in case it helps someone else who sees this.

Could you please provide a sample code using PSframework to serialize an object in a thread. I was checking its functionality and was quite confusing to me.

banyula avatar Jul 13 '19 12:07 banyula