C# – lock statement in VB.NET

c++vb.net

Does VB.NET have the equivalent of C#'s lock statement?

Best Solution

Yes, the SyncLock statement.

For example:

// C#
lock (someLock)
{
    list.Add(someItem);
}

// VB
SyncLock someLock
    list.Add(someItem)
End SyncLock