Thread spawning

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Allan Ebdrup

    #1

    Thread spawning

    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 countResultTime stamps As Hashtable = New Hashtable
    'Here I want to call CacheUpdateCoun t(countResults,
    countResultTime stamps, Guid) in a new asyncronous thread updating the static
    cache
    Return countResults(Gu id)
    End function

    Private Function CacheUpdateCoun t(ByRef countResults As Hashtable, ByRef
    countResultTime stamps As Hashtable, ByVal Guid)
    'Update static cache
    end function

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

    Kind Regards,
    Allan Ebdrup


Working...