Is there a lock statement in VB.NET?

C#vb.net

C# Problem Overview


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

C# Solutions


Solution 1 - C#

Yes, the SyncLock statement.

For example:

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

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

Solution 2 - C#

It is called SyncLock example:

Sub IncrementWebCount()
    SyncLock objMyLock
        intWebHits += 1
        Console.WriteLine(intWebHits)
    End SyncLock
End Sub

Solution 3 - C#

Yes, it's called SyncLock

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioniburlakovView Question on Stackoverflow
Solution 1 - C#Jon SkeetView Answer on Stackoverflow
Solution 2 - C#CSharpAtlView Answer on Stackoverflow
Solution 3 - C#Chris DunawayView Answer on Stackoverflow