Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a shared & synchronized variable to hold a counter #58

Open
banyula opened this issue Sep 28, 2018 · 2 comments
Open

Using a shared & synchronized variable to hold a counter #58

banyula opened this issue Sep 28, 2018 · 2 comments

Comments

@banyula
Copy link

banyula commented Sep 28, 2018

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.

@sheldonhull
Copy link

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.

@banyula
Copy link
Author

banyula commented Jul 13, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants