0

Hi!

I want to run multiple threads at the same time, and each thread has foreach loop accessing a listbox, so each thread checks every item in listbox, instead that each thread checks only one item, or skip an item if it has already been checked by other thread.
Now, i would like to syncronize them so each thread checks only one item, which has not been checked by any other thread previously

Thanks for any help in advance!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Erco21
0

You'll need some sort of indicator that tells a thread that the item has already been checked, and a locking mechanism to prevent the threads from attempting to access that same object.

You should probably read this.

0

well, i already tried to make a global String which was supposed to hold the last used item, and if current item is in that variable, it gets added to another listbox
however, that didnt work as i expected it to work; it instantly added all unchecked items to checked list, and resumed again, but with only one thread

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.