interlock exchange issue
How to fix the compile error when interlock exchange a bool type variable?
public static void Main()
bool b = false;
// error CS0452: The type 'bool' must be a reference type in order to use it as parameter
// 'T' in the generic type or method 'System.Threading.Interlocked.Exchange<T>(ref T, T)'
bool a = Interlocked.Exchange(ref b, true);
thanks in advance,
The MSDN examples state that you should be using an int instead. While this is also a non-referencetype, there are overloads of Exchange for int.