C#.Net
-
Is its possible that two processes in a computer write the information Simultaneously in one XML file(test.XML) OR I have to use Database Please guide me if it is possible. Ashwani
-
Is its possible that two processes in a computer write the information Simultaneously in one XML file(test.XML) OR I have to use Database Please guide me if it is possible. Ashwani
I read some where that the XML classes prevent concurrent writes to an XML file. However, you will have other problems. For example, if user "A" modifies one part of the document and user "B" modifies another part, either user "A" or "B" will lose his\her modification dependent upon who wrote to the file last.
-
I read some where that the XML classes prevent concurrent writes to an XML file. However, you will have other problems. For example, if user "A" modifies one part of the document and user "B" modifies another part, either user "A" or "B" will lose his\her modification dependent upon who wrote to the file last.
Thanks, My requirement is to only Insert the new records in a XML file( no modification, deletion) Ashwani
-
Thanks, My requirement is to only Insert the new records in a XML file( no modification, deletion) Ashwani
You may loose inserted data too! 1. User A loads file. 2. User B loads file. 3. User A inserts data and saves it. 4. User B inserts data and saves it, and User A inserted data is lost.
-
You may loose inserted data too! 1. User A loads file. 2. User B loads file. 3. User A inserts data and saves it. 4. User B inserts data and saves it, and User A inserted data is lost.
Right ! :) Ok ! I was thinking what about accessing SQL database by Two Threads simultaneously !! I am planning to do something like, [One thread is generating email address and email message and dump that record in SQL, another thread read email message from that SQL, send email and after that delete that record and scan any new record inserted] A) Thread A inserts record in SQL B) Thread B reads a record from SQL, may be the same one which was just inserted by Thread A. C) Thread B do some work based on the information of that record. D) Thread B Delete that record after finishing its work, and then look for new record again which was inserted by Thread A. ::: Now, Is there any chance of conflict ? I was worried about one thing, When Thread A is inserting record, does it lock the Database so that Thread B cannot read or delete any other record (not the exactly one which is being inserted) ? Or, When Thread B is reading or Deleting record, does it lock the database so that thread A cannot insert new record ? Thanks and regards... -- modified at 0:26 Thursday 23rd February, 2006
-
Right ! :) Ok ! I was thinking what about accessing SQL database by Two Threads simultaneously !! I am planning to do something like, [One thread is generating email address and email message and dump that record in SQL, another thread read email message from that SQL, send email and after that delete that record and scan any new record inserted] A) Thread A inserts record in SQL B) Thread B reads a record from SQL, may be the same one which was just inserted by Thread A. C) Thread B do some work based on the information of that record. D) Thread B Delete that record after finishing its work, and then look for new record again which was inserted by Thread A. ::: Now, Is there any chance of conflict ? I was worried about one thing, When Thread A is inserting record, does it lock the Database so that Thread B cannot read or delete any other record (not the exactly one which is being inserted) ? Or, When Thread B is reading or Deleting record, does it lock the database so that thread A cannot insert new record ? Thanks and regards... -- modified at 0:26 Thursday 23rd February, 2006
If you were back to the xml file thing, you could have a common write function used by the two threads, and a lock(this) at the start of the function so that the other thread cannot execute that method when one thread is inside it. After every write into the file, you will have to save the file, so that when the next guy opens it, he will be appending to the already existing content of the xml file. There has to be more to life than just this
-
If you were back to the xml file thing, you could have a common write function used by the two threads, and a lock(this) at the start of the function so that the other thread cannot execute that method when one thread is inside it. After every write into the file, you will have to save the file, so that when the next guy opens it, he will be appending to the already existing content of the xml file. There has to be more to life than just this
Hello, I understood about the XML file, but what about the SQL database file. Do i need to lock the database for similar operation ? Here I dont have multi user, but multi thread. I have two threads, one will insert record, another will read and delete record. at the same time, is there any chance of conflict and Hang ? Do I need to lock the database ?
-
Hello, I understood about the XML file, but what about the SQL database file. Do i need to lock the database for similar operation ? Here I dont have multi user, but multi thread. I have two threads, one will insert record, another will read and delete record. at the same time, is there any chance of conflict and Hang ? Do I need to lock the database ?
If you are using independent connections as suggested already earlier, it all comes down to whether the database maintains integrity of transactions. Yes it does, that is why we pay so much money to use an Oracle or SQL Server database. If thread A is inserting a row into the database, the concerned tables will be locked and thread B will be made to wait before it can read or delete stuff. So, yes, database is the most convinient method, albeit a tad slower. There has to be more to life than just this