Do i have a problem? possible multiread from xmlfile

  • Thread starter Thread starter Flare
  • Start date Start date
F

Flare

H

I have a dll lib wich contains a static method to read and return a result
from a xmlfile.

But is possible that this dll could be called at the same time from muliple
threads. Is this a problem when its readonly access to the file?

I mean do i need some kind of lock on the method so only one thread can
access it? My thougt was that i would have a problem if the methid should
read from the xmlfile from 2 threads

The method goes like this....

private static string GetUrl(string section, string asmxfile)
{
string CompleteUrl = null;

try
{
XmlDocument m_doc = new XmlDocument();
m_doc.Load("webservices.xml");

XmlNode node_webserviceurl =
m_doc.DocumentElement.SelectSingleNode("//config/webserviceurl");
.....
.....
.... etc.
}}

Best reagards
Anders
 
Hi Anders,

When two readers read from the same source they will both
get the same result.

When a reader and a writer access the same data, there is the
problem of who does what when. If there are stages in the process,
the reader may read data which is halfway changed - thus getting
bad data. That's the situation when you need locking.

So you're ok with what you've got.

Regards,
Fergus
 
When a reader and a writer access the same data, there is the
problem of who does what when. If there are stages in the process,
the reader may read data which is halfway changed - thus getting
bad data. That's the situation when you need locking.

So you're ok with what you've got.

Perfect. Its just that the idea of having two objects opening the same file
a the same time could give me problems when one of them tried to "close" the
reader while the other still were reading....og something like that :)

Thax for your answere.
Anders, Denmark
 
Back
Top