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;
}
}
}