Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

How exactly does SyncLock work

$
0
0

So let's say I have an ASP.Net website, and I place some object to Cache in the page A.aspx.vb as follows:

Dim o As New Object()
Context.Cache.Insert(key, o, ...other required arguments)

Now in the page B.aspx.vb I do this:

Dim o as Object  = Context.Cache(key)

If o IsNot Nothing
    SyncLock o
        ...do something with o
    End SyncLock
End If

Now if two instances of the page B.aspx.vb execute simultaneously, and use the same key to retrieve o from cache, will one page wait for the other to exit the SyncLock region? o is an instance variable, but for both instances of the class representing my page B it points to the same instance of the object in Cache.


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>