According to Web, I found the following codes, which is equivalent of C# Volatile for VB.NET.
Code reference: How do I specify the equivalent of volatile in VB.net?
Function VolatileRead(Of T)(ByRef Address As T) As T
VolatileRead = Address
Threading.Thread.MemoryBarrier() '*** I mean this line ***'
End Function
Sub VolatileWrite(Of T)(ByRef Address As T, ByVal Value As T)
Threading.Thread.MemoryBarrier() '*** I mean this line ***'
Address = Value
End Sub
I want to know exactly, What does Threading.Thread.MemoryBarrier() do and how, when I execute it in above code ?
Can I write a method equivalent to MemoryBarrier() in C# myself?