You are implementing a state machine in a multithreaded class. You need to check what the current state is and change it to the new one on each step. Which method do you use?
Interlocked.CompareExchange(ref currentState, ref newState, expectedState)
Interlocked.Exchange(ref currentState, newState)
© 2017 QuizBucket.org