1

While learning about creating singleton objects and the problems when using them with threads in VB.NET i found the following post How do I specify the equivalent of volatile in VB.net?

The marked answer shows the following methods

Function VolatileRead(Of T)(ByRef Address As T) As T
    VolatileRead = Address
    Threading.Thread.MemoryBarrier()
End Function

Sub VolatileWrite(Of T)(ByRef Address As T, ByVal Value As T)
    Threading.Thread.MemoryBarrier()
    Address = Value
End Sub

But how do i use this methods in my application to create a singleton object?

Community
  • 1
  • 1
  • The better singleton patterns don't require volatile anyway. Either use `Lazy(Of T)` or a type initializer. – Jon Skeet Jul 13 '14 at 18:56

0 Answers0