So I have a common instance of a class shared between 2 other classes on different threads. let me explain:
public class Config
{
public IEnumerable<Regex> GetSafeRuleRegex()
{
foreach (string rule in this.SafeRules)
{
Regex regex = null;
try
{
regex = new Regex(rule, RegexOptions.IgnoreCase);
}
catch(Exception e)
{
Trace.Write(e.Message);
}
if (regex != null)
yield return regex;
}
}
}
public class Dispatcher
{
public void Start()
{
var config = new Config();
for (var i = 0; i < 10; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(o => new Item(config)));
}
}
}
will this cause locking issues?