synclock

SyncLock on SyncRoot

I have created a synchronized queue and am using SyncLock on the SyncRoot property of that queue when I invoke the Enqueue/Dequeue methods. The methods are invoked from instances of standard producer/consumer classes. Is that a proper use of the SyncRoot property? Would it be better practice to create a private shared object in each c...

Is it a bad idea to put frequent file I/O operations within a SyncLock block?

Say I have some code that does this: Public Function AppendToLogFile(ByVal s As String) As Boolean Dim success As Boolean = True Dim fs As IO.FileStream = Nothing Dim sw As IO.StreamWriter = Nothing Static LogFileLock As New Object() SyncLock LogFileLock Try fs = New IO.FileStream(LogFilePath) ...

jQuery Ajax SyncLock

I have a couple of buttons that users can click to load content with jQuery's $.ajax. All the buttons load the content into the same div tag. The problem is that if users click multiple times quickly, the content can flash several times before landing on the correct content. What workaround do I have for this? I was thinking of somethin...

Why use SyncLocks in .NET for simple operations when Interlocked class is available?

I've been doing simple multi-threading in VB.NET for a while, and have just gotten into my first large multi-threaded project. I've always done everything using the Synclock statement because I didn't think there was a better way. I just learned about the Interlocked Class - it makes it look as though all this: Private SomeInt as Integ...

What is the difference between `Synclock syncroot` and `SyncLock Me`?

vb.Net multithreading question: What is the difference between SyncLock syncRoot ''# Do Stuff End SyncLock -and- SyncLock Me ''# Do Stuff End SyncLock ...

How does lock(syncRoot) make sense on a static method?

The following code is excerpted from the (Windows Identity Foundation SDK) template that MS uses to create a new Security Token Service Web Site. public static CustomSecurityTokenServiceConfiguration Current { get { var key = CustomSecurityTokenServiceConfigurationKey; var httpAppState = HttpContext.Curren...

Synclock a section of code while waiting for ShowDialog to return

I'm having trouble working out how to lock my application out of a section of code while it waits for a response from an external program I've used Synclock on a section of code with the Me object in the expression. In this Synclock I call an overridden ShowDialog method of a dialog box, which has a timeout parameter, but does return th...

SyncLock on two objects

Suppose I have two objects a and b. I want to SyncLock on both objects. Is this feasible? Can it be done by nested SyncLock statements? What are the dangers of such an operation? Edit Perhaps I should ask, how can one refactor to avoid deadlocks? ...

.NET SyncLock order deadlock

If I have two Synclocks synclock a synclock b end synclock end synclock am I in danger of a deadlock if I never have synclock b synclock a end synclock end synclock in my code, but I do synclock on a or b randomly? ...

How accurate is the GPS Clock ?

In my company we do have critical systems that require an accurate time. As so, we have an NTP server appliance with an outdoor GPS antenna that receives the time from the GPS satellites. My questions are: How accurate is the time clock? Is it worth it to keep this way or use another external NTP (US-GOV, NASA, etc) ? Thanks, ...