public void SendMessages(MessageSet set) { if (!Faulted) _proxy.ProcessMessagesAsync(set, set); }
private void DoSend(List<Message> msgs) { if (Faulted) return; var msgset = new MessageSet { Messages = new System.Collections.ObjectModel.ObservableCollection<Message>(), ApplicationId = _sender.ApplicationId, Number = _nextMessageId++ }; foreach (Message msg in msgs) { if (msg != null) msgset.Messages.Add(msg); } try { // TODO: REVIEW THIS // Per MSDN: // if the system runs continuously, TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days, // then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days. msgset.Tick = Environment.TickCount; msgset.Timestamp = DateTime.Now; if (ThrottleSettings.Default.SimulateNetworkTrafficOrder) { lock (_outboundQueueSync) { _outboundQueue.Enqueue(msgset); Monitor.Pulse(_outboundQueueSync); } } else { Platform.Log(LogLevel.Debug, "<== {0}: MSG # {1}: Count: {2}", msgset.Tick, msgset.Number, msgset.Messages.Count); if (!Faulted) _sender.SendMessages(msgset); Platform.Log(LogLevel.Debug, "<Complete {0}: MSG # {1}: Count: {2}", msgset.Tick, msgset.Number, msgset.Messages.Count); // TODO: REVIEW THIS // Per MSDN: // if the system runs continuously, TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days, // then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days. ApplicationActivityMonitor.Instance.LastActivityTick = Environment.TickCount; } } catch (Exception e) { // happens on timeout of connection HandleException(e); // In some case, this is not necessary because the connection is already faulted. // But let's do it anyway. if (!Faulted) _sender.Disconnect(e.Message); } }