Questions tagged [synclock]

SyncLock is the VB.NET keyword for its locking statement.

SyncLock is the VB.NET keyword for its locking statement, allowing any non-structure type to be locked by a transaction.

46 questions
0
votes
1 answer

Do I need to thread lock value types (Boolean in particular)

I know I can't use lock (SyncLock) on a value type, as explained in this article: http://msdn.microsoft.com/msdnmag/issues/03/01/NET/ But my question is, does this mean I don't need to? or do I need to wrap the Boolean within an object, so it can be…
Ben
  • 165
  • 2
  • 14
0
votes
1 answer

SyncLock for AsyncOperation

I have a method Update() that's called by a AsyncOperation through .Post(). When I place a MessageBox in that function, I get multiple messageboxes, and I'm trying to understand why that happens. The Messagebox should halt execution of Update()…
Maestro
  • 9,046
  • 15
  • 83
  • 116
0
votes
1 answer

Remoting cache object

I'm using the following code in a singleton remoting object MBRO. This function is only called on the server side. ''' ''' Return a cached DataCentricObject ''' ''' CodingBarfield '''…
CodingBarfield
  • 3,392
  • 2
  • 27
  • 54
0
votes
0 answers

How to correctly use synclock to only allow one call to a function at a time

I have code that sends a ping to a batch of computers, and opens a VNC session to any that respond that they are online. The pings are sent in a parallel.foreach loop, and an event is raised when a reply is receieved. Despite putting a synclock…
Peter Page
  • 97
  • 3
  • 12
0
votes
1 answer

How does SyncLock Works in .Net

I have a List of objects shared by multiple threads, it sometimes generate IndexOutOfRangeException when trying to Clear. While searching for solution I found that I should use SyncLock while accessing the List. But my question if what is the…
Rajeev
  • 4,571
  • 2
  • 22
  • 35
0
votes
2 answers

asp.net global synclock object

is there a way in asp.net to make sure that a certain threaded sub is not run twice concurrently, no matter what? the code i have now is Public Class CheckClass ReadOnly Property CheckSessionsLock As Object Get If…
Yisroel M. Olewski
  • 1,560
  • 3
  • 25
  • 41
0
votes
4 answers

What should I SyncLock in this code, and where?

I have a class that has two method in it, one calls a class which creates and executes a number of threads, the other is an event handler that handles an event raised when those threads complete (and then calls the first method again). I understand…
Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
0
votes
1 answer

SyncLock not working in unit tests

I've got a Module that I'm wanting to use to cache some stuff. It's pretty simple. I wanted to shy away from the ConcurrentDictionary because it needs to be a guaranteed operation. Public Module SchemaTableCache Private lockObject As New Object …
Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
0
votes
1 answer

Is it safe to call SyncLock and MemoryBarrier even if you're not in a separate thread?

A follow-up to this post. My goal is to have only one Calculate at a time, so I have added a SyncLock: Public Sub Calculate(Optional inBack As Boolean = True) If Not inBack Then InternalCalculate(-1, False) Else If CalcThread…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
0
votes
0 answers

Does Synclock lock the object reference or the object itself?

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 …
o.comp
  • 118
  • 2
  • 4
0
votes
1 answer

Dequeue not the same as what is enqueued

Hello there stackoverflow! I'll just cut to the chase: I have a server / client program using TCP and I am having some trouble with the queue I use to put read packets in. This works by once a packet is read it's enqueued into the queue, and if the…
0
votes
1 answer

Synclock in Module Constructor?

Coming from Java where Static Block are immediately called. In VB.NET (ASP.NET) a Module Constructor isn't called until the first method is called. So, this begs the question, if I'm performing initialization within my Module's constructor do I…
user1068477
0
votes
1 answer

SyncLock the same object from two different threads

Basically I have a global variable, such as... Dim int1 as integer And then I have two asynchronous functions, such as... function bleh() int1 += 1 end function and function Meh() int1 -= 1 end function Both these functions are being…
Aaron Brown
  • 281
  • 1
  • 5
  • 13
0
votes
1 answer

Should I use SyncLock or Interlocked?

Can someone help me understand how synclock statements work? I know there are some other posts about synclock here but I was not able to follow the answers very well. I am trying to get a simple multithreading example up and running but am having…
-1
votes
1 answer

SyncLock loses lock if a function is called within the block in VB.Net

I have tried this in VB.2010 and 2019. This is a Windows Desktop app. It has a FileSystemWatcher create routine that gets control when a file is put into a folder and then processes the file via an invoked function. The invoked function must be…
QuickBooksDev
  • 125
  • 1
  • 1
  • 9