R
Robin Tucker
I have a class called "CacheManager" that stores both (1) requests to fetch
images into the cache and (2) fetched and cached images.
My main process controls requests to fetch items into the cache (a stack)
and a worker thread services those requests, fetching the images from the
database and storing them in the cache (a hashtable).
Given that both these processes access the same instance (obviously) and
manipulate both the stack and the cache, through different methods, how can
I ensure that the two are synchronized correctly? At the moment, requests
to clear the cache (empty it, for example, when the user changes folder)
result in the worker thread failing to update the cache when it completes
(because the collection is now empty).
What I would like to do is synchronise an entire class, such that no method
on the class can be executed while any other method on that class is
currently executing.
Is this possible?
Thanks
Robin
images into the cache and (2) fetched and cached images.
My main process controls requests to fetch items into the cache (a stack)
and a worker thread services those requests, fetching the images from the
database and storing them in the cache (a hashtable).
Given that both these processes access the same instance (obviously) and
manipulate both the stack and the cache, through different methods, how can
I ensure that the two are synchronized correctly? At the moment, requests
to clear the cache (empty it, for example, when the user changes folder)
result in the worker thread failing to update the cache when it completes
(because the collection is now empty).
What I would like to do is synchronise an entire class, such that no method
on the class can be executed while any other method on that class is
currently executing.
Is this possible?
Thanks
Robin