Is there some practical reason why the .NET team decided not to support Boolean in Interlocked.Exchange operation?
One of the usage examples is when you want to guarantee
if you need a simple solution, you can use the object field to set/get boolean value.
private object _isRemoved;
public bool isRemoved
{
get
{
object returnVal = Interlocked.CompareExchange(ref _isRemoved, false, null);
return returnVal != null && (bool)returnVal;
}
set
{
Interlocked.Exchange(ref _isRemoved, value);
}
}