C# prevent access to all object methods from other threads
问题 I have an object that have to be used by only a single Thread at a time. For example my Object contains 3 methods A , B and C and I want to lock the object (all the methods/attributes are locked) if a Thread access the method A . The main difficultie is that I can't modify the code of that object. I have to prevent multithreads access where i'm calling the object. My first thought was to use the singleton pattern but i didn't manage to make it work! 回答1: If you can't change the code of the