请问用vb.net怎么样实现单件模式中的double check

BossFriday 2009-01-07 08:53:11
我是写c#的,VB.net不会写。

Public ReadOnly Property CachedTables(ByVal context As CallContext) As Cache.CachedTableCollection
Get
Dim siteTableList As SiteCachedTables = Nothing

SyncLock _cachedTablesDictionary
If Not _cachedTablesDictionary.TryGetValue(context.SiteCode, siteTableList) Then

siteTableList = CType(System.Threading.Thread.VolatileRead(New SiteCachedTables(context.SiteCode, _host.GetTableList(context))), SiteCachedTables)


_cachedTablesDictionary.Add(context.SiteCode, siteTableList)
End If
End SyncLock

......
End Get
End Property

这样在多线程的情况还是有问题,估计我写的这个:VolatileRead 就不对。
VB.net中查了一下,没有Volatile这个关键字。那么这里我如何控制:_cachedTablesDictionary.Add(..)呢????
...全文
63 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
HBJMSHOP 2009-01-07
  • 打赏
  • 举报
回复
double check ,不太明白

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧