locking

Locking XML file in Web Application

拥有回忆 提交于 2019-12-11 03:06:28
问题 We have a website application which acts as a form designer. The form data is stored in XML file. Each form has it's own xml file. When i edit a form, i basically recreate the XML file. public void Save(Guid form_Id, IEnumerable<FormData> formData) { XDocument doc = new XDocument(); XElement formsDataElement = new XElement("FormsData"); doc.Add(formsDataElement); foreach (FormData data in formData) { formsDataElement.Add(new XElement("FormData", new XAttribute("Id", data.Id) new XAttribute(

Locking an ASP.NET application variable

好久不见. 提交于 2019-12-11 02:57:42
问题 I'm using a 3rd party web service in my ASP.NET application. Calls to the 3rd party web service have to be synchronized, but ASP.NET is obviously multi-threaded and multiple page requests could be made that result in simultaneous calls to the 3rd party web service. Calls to the web service are encapsulated in a custom object. My thought is to store the object in an application variable and use the C# lock keyword to force synchronized use of it. I'm nervous, because I'm new to multi threaded

Manually Release Postgres LOCK

青春壹個敷衍的年華 提交于 2019-12-11 02:56:46
问题 I would like to know if there´s any command to unlock or release a lock made by the same transaction. Pseudo-code FUNCTION TRANSACTION LOOP TABLE LOCK table operations... "TABLE UNLOCK WANTED" END END OF TRANSACTION END OF FUNCTION The function query can take a while as the LOOP might be large, so I would like to be able to unlock before the transaction is fully finished. 回答1: No, it isn't possible. Locks are held until end of transaction, no exceptions. Thus, you need to either: Use a

When is locking on types a good idea?

你。 提交于 2019-12-11 02:39:23
问题 From other questions I can see that locking on types is a bad idea. But it is possible to do so, so I was wondering if it is such a bad thing to do why is it allowed? I am assuming there must be good use cases for its purpose so could someone let me know what they are please? 回答1: To understand why it is a bad idea in general have a look at the article Don't lock type objects. It is allowed because the language/framework designers decided to be able to take lock on anything that derives from

MySQL: GET_LOCK limits and issues

雨燕双飞 提交于 2019-12-11 02:31:01
问题 I a need a database level synchronization. For this I'm using GET_LOCK('prefix.some_id', 0). At some moment GET_LOCK returns 1 for same key in different scripts on different hosts. What could be the problem? I need lots of those locks, 5-7k approximately. Any ideas? 回答1: MySQL 5.7.5 and MariaDB 10.0.2 both support your use case now. For MySQL see: http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock For MariaDB see: https://mariadb.com/kb/en/mariadb

Exclusive table (read) lock on Oracle 10g?

為{幸葍}努か 提交于 2019-12-11 02:27:43
问题 Is there a way to exclusively lock a table for reading in Oracle (10g) ? I am not very familiar with Oracle, so I asked the DBA and he said it's impossible to lock a table for reading in Oracle? I am actually looking for something like the SQL Server (TABLOCKX HOLDLOCK) hints. EDIT : In response to some of the answers: the reason I need to lock a table for reading is to implement a queue that can be read by multiple clients, but it should be impossible for 2 clients to read the same record.

Android get Lock Timeout Programmatically

吃可爱长大的小学妹 提交于 2019-12-11 02:22:24
问题 I am writing an app to show an activity over the lock screen when the phone is locked and screen off. When the user leave the activity, the keyguard should be shown. The common way to detect whether the phone is locked by by receiver and ACTION.SCREEN_OFF. It works perfectly if the user press lock button the lock and screen off the phone. However, after ICS, the phone may not be locked as soon as the phone is screen off. So, how can I get the lock event or how can I get the value of

Using Control.Invoke() in place of lock(Control)

陌路散爱 提交于 2019-12-11 02:04:29
问题 I am working on a multi-threaded application which needs to update a Winforms control as it progresses (A DataGridView). In order to prevent multiple access to the same shared resource, I started out with the following lock structure: if (DGV.Columns.Count >= DesiredColumnCount) return; lock(DGV) { while (DGV.Columns.Count < DesiredColumnCount) { DGV.Columns.Add(newColumn); } } I then realized that, since the DGV was created on the UI thread, it needs to be .Invoke() 'd. This changes the code

Difference between Read-Copy-Update and Reader-Writer-Lock?

天涯浪子 提交于 2019-12-11 01:55:23
问题 They look pretty much same to me from programming perspective. From what I read when updating the data, RCU needs to maintain an old copy until all readers are done, which creates large overhead. Is that the only difference when it comes to implementation ? 回答1: Read-Copy-Update (RCU): is not same as reader-writer lock, here are some of the points I can think off: Separates update and reclamation information, where both readers and writers could avoid locking altogether. From implementation

How will ReentrantLock object created inside a method's local scope work?

半腔热情 提交于 2019-12-11 01:51:58
问题 The above is a screen print from OCP 7 java se book. page 791. My question is if a new ReentrantLock object is created in a method every time and locked, how would that stop two threads from running the code block in between lock and unlock ? Won't the two threads create a ReentrantLock object each and lock it? I can imagine how this would work if lock object was a instance variable only instantiated once and never changed. (preferrably final ). Am I misunderstanding something? I had already