C# Add class instance with internal timer to a static List, is it safe?
Posted
by CodeMongo
on Stack Overflow
See other posts from Stack Overflow
or by CodeMongo
Published on 2010-05-30T20:04:52Z
Indexed on
2010/05/30
20:12 UTC
Read the original article
Hit count: 143
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?
© Stack Overflow or respective owner