I'm writing a class library that will offer some asynchronous processing, and want to try and avoid running into threading issues later on down the line. So I'm after any suggestions people can make to avoid running into issues later on, and instead start with a good design.
Some of the situations that I can see that might cause problems, and am not neccessairly sure the best way to resolve:
1) I have a class that takes an IEnumerable and uses a ToList to construct an IList. The T's are a class declared as public within my assembly. Upon starting an async process this IList is used to create a new collection, however at this point the calling assembly may be modifying the original T's used to generate my new internal collection.
2) I have a Boolean property that I'm expecting the user to use in a polling loop. I'm fairly sure that this won't be a problem with me setting the property in my assembly?
3) I regularly used an internal collection that needs to be used on two seperate threads. I'm currently planning to use a synchronized collection and clone it whenever I need a copy... although I'm hoping this won't be too slow.
4) Throughout my async method I'm wanting to fire events whenever the progress or status changes. Do I need to be aware of anything when firing events from processing threads? Again with some of these I need to pass a variable which will be taken as a clone of something used internally within the processing threads to try and avoid any issues with the user changing it.
Thanks in advance for any assistance!
Ian