What is the VB.NET keyword equivalent of C# "volatile"?
If there is no keyword what mechanism is the equivalent?
What is the VB.NET keyword equivalent of C# "volatile"?
If there is no keyword what mechanism is the equivalent?
Duplicate:
http://stackoverflow.com/questions/929146/how-do-i-specify-the-equivalent-of-volatile-in-vb-net
There is no equivelent to C#'s volatile keywword in VB.NET. Volatile in C# just makes sure the compiler handles things differently when generating the IL, but the VB.NET compiler does not have this option.
You can work around it this way (taken from this blog post):
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
link textI found this article on the web about not needing it:
http://www.developerfusion.com/article/5184/multithreading-in-vbnet/7/