How to create a list <string> {get; set;} for the stream,
I have a class that requires dynamic tuning of the list. I also call this class 10 or so different using Threading.
public static List<string> MyList {get;set;}
I am new to streaming since I was told that it is unsafe. I have a question, how to create an instance of MyList
for a thread?
The example will be amazing!
Use the ThreadStatic
attribute.
[ThreadStatic] private static List<string> _myList; public static List<string> MyList { get { return _myList; } set { _myList = value; } }
In addition, it is usually better for the class containing the class to have control over the collection; this would mean the absence of a setter and receiver, visible from the outside, that returns either a copy or a read-only collection.
But this may not affect . Each thread will have its own copy of the collection. You may need to look at locks or rethink your design.