/// <summary> /// Update is called once per frame. /// </summary> public void Update() { // Note: Don't call callbacks while locking receivedNotificationQueue, otherwise there's a risk // that callback might introduce an operations which would create a deadlock lock (this) { if (m_ReceivedNotificationQueue.Count == 0) { return; } var temp = m_ReceivedNotificationQueue; m_ReceivedNotificationQueue = m_ReceivedNotificationList; m_ReceivedNotificationList = temp; } foreach (var notification in m_ReceivedNotificationList) { try { AndroidNotificationCenter.ReceivedNotificationCallback(notification); } catch (Exception e) { Debug.LogException(e); } } m_ReceivedNotificationList.Clear(); }
public void Update() { lock (receivedNotificationQueue) { while (receivedNotificationQueue.Count > 0) { var intentData = receivedNotificationQueue.Dequeue(); AndroidNotificationCenter.ReceivedNotificationCallback(intentData); } } }
/// <summary> /// Update is called once per frame. /// </summary> public void Update() { // Note: Don't call callbacks while locking receivedNotificationQueue, otherwise there's a risk // that callback might introduce an operations which would create a deadlock lock (s_ReceivedNotificationQueue) { s_ReceivedNotificationList.AddRange(s_ReceivedNotificationQueue); s_ReceivedNotificationQueue.Clear(); } foreach (var notification in s_ReceivedNotificationList) { AndroidNotificationCenter.ReceivedNotificationCallback(notification); } s_ReceivedNotificationList.Clear(); }
public void Update() { var tempList = new List <AndroidJavaObject>(); // Note: Don't call callbacks while locking receivedNotificationQueue, otherwise there's a risk // that callback might introduce an operations which would create a deadlock lock (receivedNotificationQueue) { tempList.AddRange(receivedNotificationQueue); receivedNotificationQueue.Clear(); } foreach (var t in tempList) { AndroidNotificationCenter.ReceivedNotificationCallback(t); } }