How to fire off a asych thread in a web application, and gaurantee only 1 thread fires?
- by Blankman
I want to cache a object in memory. Regenerating the object when the cache expires is fairly expensive, so I want to do the following:
When the cache is "about" to expire, I want to fire off a asychronous thread that will go and rebuild the object and then reset the cache.
One thing I am worry about is multiple threads firing to fetch the object to cache, I only want a single thread doing this, realizing many people will be hitting the website.
This might not be the best use case to do this, but I want to know how to do this sort of thing.