private void updateTouches()
{
if (frameStartedInvoker != null) frameStartedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
// need to copy buffers since they might get updated during execution
List<TouchPoint> beganList = null;
List<int> updatedList = null;
List<int> endedList = null;
List<int> cancelledList = null;
lock (touchLock)
{
if (touchesBegan.Count > 0)
{
beganList = touchPointListPool.Get();
beganList.AddRange(touchesBegan);
touchesBegan.Clear();
}
if (touchesUpdated.Count > 0)
{
updatedList = intListPool.Get();
updatedList.AddRange(touchesUpdated);
touchesUpdated.Clear();
}
if (touchesEnded.Count > 0)
{
endedList = intListPool.Get();
endedList.AddRange(touchesEnded);
touchesEnded.Clear();
}
if (touchesCancelled.Count > 0)
{
cancelledList = intListPool.Get();
cancelledList.AddRange(touchesCancelled);
touchesCancelled.Clear();
}
}
if (beganList != null)
{
updateBegan(beganList);
touchPointListPool.Release(beganList);
}
if (updatedList != null)
{
updateUpdated(updatedList);
intListPool.Release(updatedList);
}
if (endedList != null)
{
updateEnded(endedList);
intListPool.Release(endedList);
}
if (cancelledList != null)
{
updateCancelled(cancelledList);
intListPool.Release(cancelledList);
}
if (frameFinishedInvoker != null) frameFinishedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
}