C
Chris Dunaway
I was using a Queue object like this to create my own specialized queue
class for use with my own objects:
Public Class MySpecializedQueue
Private q As New Queue
Public Sub Enqueue(obj As MyCustomClass)
SyncLock q.SyncRoot
q.Enqueue(obj)
End SyncLock
End Sub
Public Function Dequeue() As MyCustomClass
SyncLock q.SyncRoot
Return DirectCast(q.Dequeue, MyCustomClass)
End SyncLock
End Function
End Class
What happens if there is an exception inside the SyncLock block for
some reason? Will the q now be locked to other threads? Or does the
End Synclock automatically happen?
Chris
class for use with my own objects:
Public Class MySpecializedQueue
Private q As New Queue
Public Sub Enqueue(obj As MyCustomClass)
SyncLock q.SyncRoot
q.Enqueue(obj)
End SyncLock
End Sub
Public Function Dequeue() As MyCustomClass
SyncLock q.SyncRoot
Return DirectCast(q.Dequeue, MyCustomClass)
End SyncLock
End Function
End Class
What happens if there is an exception inside the SyncLock block for
some reason? Will the q now be locked to other threads? Or does the
End Synclock automatically happen?
Chris