C# Add class instance with internal timer to a static List, is it safe?
- by CodeMongo
My program has a static list of type classA. ClassA implements a threading timer that executes a task. The list may contain as many instances of classA as desired. Is this technique causing threading issues where the class instances can block each other? It that is the case how can I solve the that problem. ex:
static List<MyClassType> list=null;
void static Main()
{
list = new List<MyClassType>();
var a = new MyClassType();
var b = new MyClassType();
list.Add(a);
list.Add(b);
Console.ReadKey();
}
a and b will execute theire internal task based on the timer.Is it s bsd technique? Why?