private void removeConnections(int difference) { for (int i = 0; i < difference * -1; i++) { if (notificationConnections.Count > 0) { NotificationConnection toClose = notificationConnections[0]; notificationConnections.RemoveAt(0); toClose.Close(); toClose.Dispose(); toClose = null; } } }
private void addConnections(int difference) { for (int i = 0; i < difference; i++) { NotificationConnection newCon = new NotificationConnection(Host, Port, P12FileBytes, P12FilePassword); newCon.SendRetries = SendRetries; newCon.ReconnectDelay = ReconnectDelay; newCon.Error += new NotificationConnection.OnError(newCon_Error); newCon.NotificationFailed += new NotificationConnection.OnNotificationFailed(newCon_NotificationFailed); newCon.NotificationTooLong += new NotificationConnection.OnNotificationTooLong(newCon_NotificationTooLong); newCon.NotificationSuccess += new NotificationConnection.OnNotificationSuccess(newCon_NotificationSuccess); newCon.Connecting += new NotificationConnection.OnConnecting(newCon_Connecting); newCon.Connected += new NotificationConnection.OnConnected(newCon_Connected); newCon.Disconnected += new NotificationConnection.OnDisconnected(newCon_Disconnected); newCon.BadDeviceToken += new NotificationConnection.OnBadDeviceToken(newCon_BadDeviceToken); notificationConnections.Add(newCon); } }