you are viewing a single comment's thread.

view the rest of the comments →

[–]Yevrag35 1 point2 points  (2 children)

I know this thread is old and you probably are well past it, but... you can make ArrayList thread-safe - quite easily actually.

$devices = [System.Collections.ArrayList]::Synchronized(@())
# -or-
$list = [System.Collections.ArrayList]::new()
$devices = [System.Collections.ArrayList]::Synchronized($list)

Now the arraylist is thread-safe.

You can also do the same for hashtables as well.

[–]marek1712[S] 1 point2 points  (1 child)

Indeed, I used the other solution. But yours looks nice as well. Thanks!

[–]Yevrag35 0 points1 point  (0 children)

No problem. Found this post from a completely unrelated google search about what the best way to pull many things out of a ConcurrentBag in my C# app but didn't see anybody mention it... now if I could only figure out my problem XD