/// <summary> /// Dequeues a single message and sends it immediately /// </summary> private void MessageSendCallback(object state) { lock (_messagequeue) { if (_messagequeue.Count > 0) { DirectIM message = _messagequeue.Dequeue(); // Turn off the timer while a message is being sent, it...could take a while _messagetimer.Change(Timeout.Infinite, Timeout.Infinite); SendPacket(message.ToByteArray(), new AsyncCallback( delegate { // If the message has attachments, start a writer to spool out the data, reset the timer when it's done if (message.Attachments.Count > 0) { DirectIMDataWriter writer = new DirectIMDataWriter(this, message); writer.DataWriterComplete += new DataWriterCompleteHandler( delegate { _messagetimer.Change (500, 500); }); writer.Write(); } else { // Reset the timer right away _messagetimer.Change(500, 500); } })); } } }
/// <summary> /// Dequeues a single message and sends it immediately /// </summary> private void MessageSendCallback(object state) { lock (_messagequeue) { if (_messagequeue.Count > 0) { DirectIM message = _messagequeue.Dequeue(); // Turn off the timer while a message is being sent, it...could take a while _messagetimer.Change(Timeout.Infinite, Timeout.Infinite); SendPacket(message.ToByteArray(), new AsyncCallback( delegate { // If the message has attachments, start a writer to spool out the data, reset the timer when it's done if (message.Attachments.Count > 0) { DirectIMDataWriter writer = new DirectIMDataWriter(this, message); writer.DataWriterComplete += new DataWriterCompleteHandler( delegate { _messagetimer.Change (500, 500); }); writer.Write(); } else { // Reset the timer right away _messagetimer.Change(500, 500); } })); } } }