In a public static class I have the following local method:
private static int GetMaxFromList(IEnumerable<int> list)
{
var result = 0;
foreach (var i in list)
{
if (i > result) result = i;
}
return result;
}
This method is called by some of the public methods within the class (example):
public static bool IsIntegrityOfDataSetGood(DataSet dataSet, KeyValuePair<string, List<int>> tableAndColumnIndexes)
{
return IsIntegrityOfDataSetGood(dataSet, tableAndColumnIndexes.Key) &&
dataSet.Tables[tableAndColumnIndexes.Key].Columns.Count > GetMaxFromList(tableAndColumnIndexes.Value);
}
Note that this public method also calls another public method within the class.
The class methods only work with data sent to them through parameters, but I am worried that the calls between the static methods will mess up thread safety. Am I right to worry?
Forgot to mention that this code resides in a .NET 2.0 project.
No, this will not foil your thread-safety.
But whether it really is thread-safe depends on where
tableAndColumnIndexescomes from and what other Threads have access to it. In other words, it depends on the calling code.