Mutex needed? multiple readers of an XML file

  • Thread starter Thread starter pokémon
  • Start date Start date
P

pokémon

Just wondering if I need to add a Mutex around this section (and if so,
where) where multiple apps will be making the static method call:

public static bool GetDBConn(string dbName, out string connString, out
string dbType)
{
string XMLPath = ConfigurationSettings.AppSettings["xmlFilePath"];

XmlDocument ConnXMLDoc = new XmlDocument();

ConnXMLDoc.Load(XMLPath);

// ... etc ...

}
 
pokémon said:
Just wondering if I need to add a Mutex around this section (and if so,
where) where multiple apps will be making the static method call:

public static bool GetDBConn(string dbName, out string connString, out
string dbType)
{
string XMLPath = ConfigurationSettings.AppSettings["xmlFilePath"];

XmlDocument ConnXMLDoc = new XmlDocument();

ConnXMLDoc.Load(XMLPath);

// ... etc ...

}

You need some synchronization device (like mutex) only when you have some
shared resource accessed/updated by more than one thread (process.) I don't
know what you want to do in the "...etc..." but your code so far doesn't
need synchronization.
 
Back
Top