I have read a number of posts on this subject, but I'm still just a little fuzzy how C# handles parameters in methods when called from multiple threads.
I have a series of utility methods that need to be called from about 60+ threads. It's a process that downloads patient data for roughly 20,000-30,000 patients every day. For the most part, the methods look like this.
Public Static SomeClass
{
public static string StringToSQLBool(string s)
{
if (s.Trim() == "")
{
return "Null";
}
else
{
if (s.ToLower() == "true")
{
return "1";
}
{
return "0";
}
}
}
public static string DateToSQLAnsiStr(string ADate)
{
try
{
if (ADate.Trim() != "")
{
DateTime d = Convert.ToDateTime(ADate);
return "{d '" + d.Year.ToString() + "-" +
d.Month.ToString().PadLeft(2, '0') + "-" +
d.Day.ToString().PadLeft(2, '0') + "'}";
}
else
{
return "Null";
}
}
catch
{
return "Null";
}
}
}
As I understand it, as long as the parameters are used in the method that are singular to the calling thread, then it would be considered safe.
Are these thread-safe without locking?