Hey,

I have a class (static) with a static collection property (public).
I have a background worker which iterates through the collection and assigns some properties (it is quite time consuming).

There is also a refresh method (public) which can be called to refresh the collection.

The problem is this:
While the background worker is working iterating through the collection, the refresh method is called from somewhere else resetting the collection and causing the background worker to generate an error.

My question is this:
Is there a way to Lock the collection so that it cannot be modified while the background worker is working on it?
I know I can use Lock(object) but that locks some lines of code. is there a way to lock a variable?

Thanks