locking

Is it possible to read-lock a file?

I'm developing an application which checks for changes made to a file by a separate program (not written by me). If a change is detected, it opens the file, reads the last line, then closes the file. I'm using the following code to make sure my program doesn't try to lock the file, but only opens it in read mode: FileStream fs = n...

Ensure a file is not changed while trying to remove it

In a POSIX environment, I want to remove a file from disk, but calculate its checksum before removing it, to make sure it was not changed. Is locking enough? Should I open it, unlink, calculate checksum, and then close it (so the OS can remove its inode)? Is there any way to ensure no other process has an open file descriptor on the file...

Good advices to use EF in a multithread program ?

Have you got some good advices to use EF in a multithread program ? I have 2 layers : a EF layer to read/write into my database a multithread service which uses my entities (read/write) and makes some computations (I use Task Parallel Library in the framework) How can I synchronize my object contexts in each thread ? Do you know a g...

Does return inside a lock makes any difference ?

Sample One Public _objLock As Object = New Object Public ReadOnly Property MyObjects() As IEnumerable(Of Object) Get SyncLock _objLock If _myObjects Is Nothing Then _myObject = LoadMyObjects() End If Return _myObjects End SyncLock End Get End Property Sample T...

How can I insert a record and lock that row simultaneously?

I'm inserting a row using an Oracle stored procedure which is configured to use an autonomous transaction. I'd like to insert this record, commit that transaction, and then lock the newly-inserted record so that nobody else can modify it except my current session (in another transaction, obviously, since the one that inserted it is auto...

Does one PHP/application session correspond to one Oracle/database session?

I'm experiencing some behavior I did not expect. I have a synchronous procedure that is kicked off via PHP/OCI8. At the beginning of the process there is a SELECT...FOR UPDATE NOWAIT I do NOWAIT because I want users notified immediately with an error message that the process is already running, rather than having their browser wait fo...

range lock in java

I have a large array to be accessed by multiple thread. Single lock is not efficient enough.Is there a range lock class in java or scala? ...

Transaction Locked Down SQL Server 2005

Hello Guys, I have noticed something over the last few months. Each time we run a script that has a transaction statements let say we stop the query unexpectedly this action actually lock the database. The only way out is to destroy the transaction each time. I have never experience this before even though I have stopped the query in t...

Mutex locks vs Threading locks. Which to use?

hello all. My main question is does the Threading lock object create atomic locks? It doesn't say that the lock is atomic in the module documentation. in pythons mutex documentation it does say the mutex lock is atomic but it seems that I read somewhere that in fact it isn't. I am wondering if someone could could give me a bit of insight...

Is this method of file locking acceptable?

We have 10 Linux boxes that must run 100 different tasks each week. These computers work at these tasks mostly at night when we are at home. One of my coworkers is working on a project to optimize run time by automating the starting of the tasks with Python. His program is going to read a list of tasks, grab an open task, mark that ta...

Using mysql innodb as a queue?

I have two jobs pulling from a mysql table. They both want to get a row, do some work on it and update that row with the results, however I don't want them selecting the same row to update. Whats the best way using mysql/innodb engine to lock a row in the select so that it will be unavailable to other threads but allowing them to select ...

How to detect a directory is in use on Win32?

I need a programmatic way to know if a directory (as opposed to a file) is in use, for example because it is open on explorer or a CMD prompt. If the directory is in use, then it cannot be deleted. The current way I have found to do that is trying to rename it, is there a less intrusive way to do this under Windows? ...

What method is called when iPhone is locked?

I want my app to stop locating the user when the app is open, but the phone is locked, to cut down on battery usage. What delegate method is called when the user locks the phone while an app is still running and active? ...

Nhibernate Generat wrong SQL for Oracle with locking

yesterday I've been trying to make this code work inspite the fact it's just working fine with nhibrnate and SQL server but when it come to oracle it generate wrong sql UnitOfWork.Current.CreateCriteria<Bill>().Add(Restrictions.IsEmpty("ReqId")) .SetMaxResults(BatchSize).SetLockMode(LockMode.Upgrade).List<Bill>(); the generated SQL w...

SQL Server - table seems to be blocked

Using NHibernate, I have just attempted to save a graph of objects using NHibernate. The save failed due to a not-null constraint violation. I am now finding that a table in the database corresponding to one of the objects in the graph now appears to be locked. I cannot query it. Whenever I try, it just sits there doing nothing until I ...

Lock on XDocument.Save for multiple ASP.NET pages

Is it possible to use a lock on one xml file that can potentially be written to from multiple aspx pages at the same time? I'm asking because MSDN suggest that the lock statement should be used with a private static object instance as the expression, and since there are multiple pages involved i guess i can't use the same object on all t...

Keep thread waiting on windows form response?

I have a windows forms application that runs two threads simultaneously, with the UI thread running in the task bar. The UI thread actually performs completely separate functionality from the other process, but in the case that a new user logs into the application, I need to pop up a setup window from the non-UI thread. Here is the cod...

x86 LOCK question on multi-core CPUs

Is it true that the x86 ASM "LOCK" command prefix causes all cores to freeze while the instruction following "LOCK" is being executed? I read this in a blog post and it doesn't make sense. I can't find anything that indicates if this is true or not. ...

"tf.exe checkout" locks files although parameter /lock:none is used in post build

In a customer project, I need to copy a built dll to another place where it will be checked in and shared amongst different solutions. I am using a post build step to checkout the target file specifying the /lock:none parameter so that others will be able to create local release builds as well and then copy my new dll file over the old...

How do I use the LOCK ASM prefix to read a value?

I know how to use LOCK to thread-safely increment a value: lock inc [J]; But how do I read [J] (or any value) in a thread-safe manner? The LOCK prefix can't be used with mov. And if I do the following: xor eax, eax; lock add eax, [J]; mov [JC], eax; It raises an error on line 2. ...