Novice Programmer here – I have an application with two threads that I start, they then run two different loops. Someplace along the lines of the loops both threads access the same class. In one loop I am instantiating an object in the constructor of that class, then using that object in a method – Then when the second loop tries to instantiate the same class it basically just sits on the constructor and doesn’t execute that line of code.
Am I explaining my problem clear enough? Does anyone have any idea why this is happening, or more importantly why?
I have been looking into SyncLock but I don’t how I would implement this here. Should I just SyncLock my whole class, so only one loop can access it at a time? I feel like this kind of defeats the purpose of Threading then. Any help anyone can offer is appreciated.
Private Shared Variables ended up being the answer.