By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Thread spawning

P: n/a
I'm inside a function where I have a static cache, when the cache needs to
be updated I want to do it asyncronously, because updating the cache takes a
while. I want to use thread safety when writing and reading the cache (a
Mutex?)

Private Function Count(ByVal Guid)As Int32
Static Dim countResults As Hashtable = New Hashtable
Static Dim countResultTimestamps As Hashtable = New Hashtable
'Here I want to call CacheUpdateCount(countResults,
countResultTimestamps, Guid) in a new asyncronous thread updating the static
cache
Return countResults(Guid)
End function

Private Function CacheUpdateCount(ByRef countResults As Hashtable, ByRef
countResultTimestamps As Hashtable, ByVal Guid)
'Update static cache
end function

1 ) How do I spawn a new thread calling the CacheUpdateCount() method?
2) How do I ensure that I don't read and write the cache at the same time?

Kind Regards,
Allan Ebdrup
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.