I presume this atomic operation is faster than ++
. I only see advantages favoring Interlocked.Increment
. What are its disavantages?
Atomic means it is thread-safe (i.e. it is impossible for one thread to read the value while another is changing it.) Which makes it slower, not faster, due to the need to use thread synchronization mechanisms. You want to use ++ if you don't care about thread-safety. Here is some discussion on the relative performance of the ++ operator in different contexts.