private ModifyCount ( int signalCount ) : bool | ||
signalCount | int | The amount to change the current count. This may be positive or negative, but not zero. |
return | bool |
private bool ModifyCount(int signalCount)
{
while (true)
{
int oldCount = CurrentCount;
if (oldCount == 0)
return false;
int newCount = oldCount + signalCount;
if (newCount < 0)
return false;
if (Interlocked.CompareExchange(ref _count, newCount, oldCount) == oldCount)
{
//Enlightenment.Trace.AsyncCountdownEvent_CountChanged(this, oldCount, newCount);
if (newCount == 0)
_tcs.SetResult();
return true;
}
}
}