views:

817

answers:

3

Is there analogue of lock statement from c# in vb.net?

+1  A: 

Yes, it's called SyncLock

Chris Dunaway
+13  A: 

Yes, the SyncLock statement.

For example:

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

// VB
SyncLock someLock
    list.Add(someItem)
End SyncLock
Jon Skeet
Just cant compete.....:)
CSharpAtl
+4  A: 

It is called SyncLock example:

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