VB.net SyncLock Object

Posted by Budius on Stack Overflow See other posts from Stack Overflow or by Budius
Published on 2012-06-08T10:37:24Z Indexed on 2012/06/08 10:40 UTC
Read the original article Hit count: 183

I always seen on SyncLock examples people using

    Private Lock1 As New Object ' declaration
    SyncLock Lock1 ' usage

but why? In my specific case I'm locking a Queue to avoid problems on mult-threading Enqueueing and Dequeueing my data.

Can I lock the Queue object itself, like this?

    Private cmdQueue As New Queue(Of QueueItem) ' declaration
    SyncLock cmdQueue ' usage

Any help appreciated. Thanks.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about multithreading