Does Synclock lock the object reference or the object itself?

189 views Asked by At

The title says it all really but I have provided some code to demonstrate what I'm asking.

Public Class Class1
    Private Object1 As New Class2
    Private Sub Test1()
        Dim LocalObject1 As New Class3(Object1)
        Synclock Object1
            'Some code here
        End Synclock
    End Sub
End Class
Public Class2
    'Some custom object type
End Class
Public Class Class3
    Private Object2 As Class2
    Public Sub New(ObjectIn As Class3)
        Object2 = ObjectIn
    End Sub
    Public Sub DoSomeWork()
        Synclock Object2
            'Some code here
        End Synclock
    End Sub
End Class

Will the two 'Some code heres ever run concurrently (assuming that they are on seperate threads)?

0

There are 0 answers